Reading your post again. This is never going to work. This is not supposed to work.
postconnection tasks are not documented in the book because they are an internal variable and they WILL go away. as they are implemented they are very buggy: 1) they are executed after the database is closed; 2) they are executed for all installed apps, not just the one that defines the; 3) not sure they are even completely thread safe. just do this: @service.jsonrpc def delete_all(app): db(db.queue.id>0).delete() return "ok" On Feb 4, 3:05 pm, JonasR <jonas.rundb...@gmail.com> wrote: > Hi > > I lift my hat off to mdipierro and all web2py contributors. I find it > amazing. > > Here is a problem I have: > > I'm trying to spawn a post action task that needs to access the > database. > When my PostConnectionTask tries to access db I get an error: > "ERROR:root:Callback execution failed for PostConnectionTask: Cannot > operate on a closed database." > So, obviously the task runs, but can't access the db somehow. > If I run the same code as a normal action (controller) there is no > problem. > > @service.jsonrpc > def delete_all(app): > > gluon.contrib.wsgihooks.localposttasks.append( TestRunner( request, > app ) ) > return "ok" > > class TestRunner(PostConnectionTask): > def __init__(self, env, app): > PostConnectionTask.__init__(self, env) > self.application = app > > def start(self): > db(db.queue.id>0).delete() > > Anyone with a clue why? > The only documentation I've found (exept for source code) > is from Achipa in this forum "-A New Cron (and post-connection tasks)" > > My config: > Mac OS X 10.6.2 > staring web2py with: python2.5 web2py/web2py.py -a pass & > web2py Version 1.74.8 (source code) > no cron jobs defined > > cheers > Jonas -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.