[web2py] Re: How to do it: Handling import path manipulation + GAE + deferred?
Constantine, perhaps because i was not able to untangle the deferred library and paths and how to get GAE and web2py to play nice together (i remember it was a long afternoon a couple of years ago and that is about all), i found http://code.google.com/appengine/docs/python/taskqueue/functions.html which allows me to add a request to the taskqueue. now, this is different then deferred. i believe deferred is like running a python script/module sometime in the future, whereas the taskqueue is like scheduling a curl request to your server sometime in the future. once i wrapped my head around that and wrapped my script/module into a web2py controller function i was up and running in minutes. that said, have you looked into using taskqueue? what does deferred have that taskqueue does not? perhaps i missed something by giving up on deferred. christian
[web2py] Re: How to do it: Handling import path manipulation + GAE + deferred?
Thank you, I know about it but I am using deferred because I have a lot of tasks ad-hoc from a functions. Using deferred eliminates the need to create a separate url for each task.
[web2py] Re: How to do it: Handling import path manipulation + GAE + deferred?
I went in a similar problem with an webapp that needs to add routes to the Python path. I didn't need a special module. Just made the path adjustments in the app's specific routes.py module that executes once when web2py starts. Doing path modifications is troublesome (something to do with threading) Look here http://groups.google.com/group/web2py/browse_thread/thread/607e9c384ec220e0/2199c108556060e7 I belive GAE does not support the use of os and sys. Check for updates on the subject. On 6 dic, 15:03, Constantine Vasil thst...@gmail.com wrote: I am using deferred library with GAE. In order to do that I have to define a 'fix_path' module and import the 'fix_path' in the module deferred.defer. What I need to do in order deferred to work with web2py? Regards, --Constantine http://code.google.com/appengine/articles/deferred.html Handling import path manipulation Some applications, or the frameworks they use, rely on manipulating the Python import path in order to make all the libraries they need available. While this is a perfectly legitimate technique, the deferred library has no way of knowing what path manipulations you've engaged in, so if the task you're deferring relies on modules that aren't on the import path by default, you need to give it a helping hand. Failing to do this can result in your tasks failing to run - or worse, only failing intermittently. Fortunately, handling this is easy. Make sure your code that changes the import path is in a module all of its own, such as 'fix_path.py'. Such a module might look like this: import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), 'lib')) Then, import the 'fix_path' module along with your usual imports, anywhere you rely on the modified path, such as in the module you defined the functions you're calling with deferred.defer in.
[web2py] Re: How to do it: Handling import path manipulation + GAE + deferred?
Yes I know about path modifications but anything web2py related - I am listening to web2py experts ;) This thing is - deferred is very important functionality and we need this. Probably Massimo will know the answer?
[web2py] Re: How to do it: Handling import path manipulation + GAE + deferred?
Google says: if the task you're deferring* relies on modules* that aren't on the import path by default, you need to give it a helping hand. path modifications: in your link: you should not change sys.path when you have more than one thread running. The Google example: sys.path.*append*(os.path.join(os.path.dirname(__file__), 'lib')) Is not changing sys.path, but appending to it.