webapp2

AttributeError: 'unicode' object has no attribute 'pop'

倾然丶 夕夏残阳落幕 提交于 2019-12-13 08:05:48
问题 I have this piece of python code in gae. def post(self): cases=self.request.get('cases') while cases: logging.info("cases: %s " % cases) case=cases.pop() Which produces this log. INFO 2012-09-19 20:23:50,690 views.py:674] cases: [u'court1150'] ERROR 2012-09-19 20:23:50,690 webapp2.py:1553] 'unicode' object has no attribute 'pop' Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google

How to ensure that my entity will never be an orphan?

一曲冷凌霜 提交于 2019-12-13 05:51:38
问题 Sometimes, you make an entity kind that is supposed to exist in another entity. However, if it turns into an orphan, it will have no reason to exist in the datastore anymore. What happens to child datastore objects after deleting the ancestor? According to the link above, "Child entities do not get deleted when the ancestor is deleted" "child_entity.key.parent().get() will return None." If I delete the ancestor, the child will have no parent, making it an orphan. This is a problem, as there

Memory leak in Google ndb library

 ̄綄美尐妖づ 提交于 2019-12-13 01:37:12
问题 I think there is a memory leak in the ndb library but I can not find where. Is there a way to avoid the problem described below? Do you have a more accurate idea of testing to figure out where the problem is? That's how I reproduced the problem : I created a minimalist Google App Engine application with 2 files. app.yaml : application: myapplicationid version: demo runtime: python27 api_version: 1 threadsafe: yes handlers: - url: /.* script: main.APP libraries: - name: webapp2 version: latest

Persisting Webapp2 Sessions on GAE

*爱你&永不变心* 提交于 2019-12-12 20:15:09
问题 I am having trouble persisting my session variables in a webapp2 session store, while running on GAE. I have created a super simple app to reproduce the issue: class MainHandler(webapp2.RequestHandler): def post(self): session = self.session_store.get_session() previous_value = session.get("myvalue") self.response.write(previous_value) def get(self): session = self.session_store.get_session() previous_value = session.get("myvalue") self.response.write(previous_value) session["myvalue"] = "Hi!

Where is the best place to put one-time and every-time code in GAE/Python?

為{幸葍}努か 提交于 2019-12-12 13:26:00
问题 I am new to Google App Engine and Python. I am having trouble understanding some basic questions about Python apps running on Google App Engine. If I want code to execute: On every incoming request, where should I put it? We are capturing session information about what pages are viewed when by whom, and what did they do, etc. Only once when the app is started, where should I put it? I need to initialize a number of application/system variables that are used in many places in the application.

Webapp2 custom tags

ε祈祈猫儿з 提交于 2019-12-12 13:14:52
问题 I am migrating from webapp1 to webapp2 and from python 2.5 to python2.7 I had some custom tags I used with webapp.template.register_template_library('common.templatetags') and registered with: from google.appengine.ext.webapp import template register = template.create_template_register() and the corresponding decorator and everything else worked fine now I need to use webapp2 which does not have template.register..... I tried doing it this way : http://www.john-smith.me/Tag/webapp2 but it

Responding with 404 as status code in Webapp2

时光怂恿深爱的人放手 提交于 2019-12-12 02:27:46
问题 My app is dynamically generating pages by reading the URL. For example, it will handle all URLs formatted like this: [url]/word If /word is a valid URL then the app will generate a page and return it back. When the app can't find anything useful it should return a 404 page. How can I do that? More specifically how do I set the status code to 404? 回答1: From within your RequestHandler, you can simply call self.abort(404) or webapp2.abort(404) to set the error status code. References: webapp2

GAE webapp2 session handling not working when putting basehandler to a different file

时间秒杀一切 提交于 2019-12-12 01:22:27
问题 In my GAE webapp2 application, I split up my handlers in different files. So I have basehandler.py, which holds: import webapp2 from webapp2_extras import sessions class BaseHandler(webapp2.RequestHandler): def dispatch(self): # Get a session store for this request print "dispatching........" self.session_store = sessions.get_store(request = self.request) try: webapp2.RequestHandler.dispatch(self) finally: self.session_store.save_sessions(self.response) @webapp2.cached_property def session

Fetching a lot of urls in python with google app engine

。_饼干妹妹 提交于 2019-12-11 20:48:47
问题 In my subclass of RequestHandler, I am trying to fetch range of urls: class GetStats(webapp2.RequestHandler): def post(self): lastpage = 50 for page in range(1, lastpage): tmpurl = url + str(page) response = urllib2.urlopen(tmpurl, timeout=5) html = response.read() # some parsing html heap.append(result_of_parsing) self.response.write(heap) But it works with ~ 30 urls (page is loading long but it is works). In case more than 30 I am getting an error: Error: Server Error The server encountered

Which python Linux IDEs support GAE's webapp2 framework?

纵然是瞬间 提交于 2019-12-11 19:48:19
问题 I am a newbie in the world of python and I want to change that. So far all my projects have in done in text editors like gedit, but for my final I need to do something more complex and I actually want a tool that helps me do it and that does not get in the way. My final project is a dynamic website in GAE using the webapp2 framework. My objective is to find a free python IDE that supports that. So far, after checking some of the options in the wiki, my search is stalled: PyCharm supports