Hi David-
Yes, I'm using GAE's taskqueue with web2py, and it works in both the
dev and production environments. Note that in the dev environment, the
tasks do not run automatically - you will need to manually trigger
them using the http://localhost:8080/_ah/admin web console.
I wasn't able to get the url-encoded payload variable working
properly, so I tried the other method that uses a params dictionary
and it worked OK. (I'm not a python expert, so it's quite likely that
I was doing something wrong with urllib.) In any case, here is the
code snippet that works for me to create a task:
if request.env.web2py_runtime_gae: # if running on Google App Engine
from google.appengine.api.labs import taskqueue
tqparams = {'row_id':r}
taskqueue.add(
url=URL(r=request, c='mycontroller', f='call/run/taskfunction'),
params=tqparams,
)
and the controller file that gets called has these lines in it
(simplified for this example):
def call():
return service()
@service.run ## we'll use this to enable this as a taskqueue-
friendly URL
def taskfunction():
"""
For security, this URL should be restricted to the admin user in
app.yaml
"""
return dict(row_id=request.vars.row_id)
On Jul 31, 11:38 am, David Watson <[email protected]> wrote:
> Has anybody had any luck getting the taskqueue from google app engine
> to work in web2py? I presume that it should work under dev_appserver,
> but isn't working for me.
>
> I defined a simple default controller based on the gae example at the
> google blog:
>
> def process_post_file():
> rows=db(db.files.processed=='False').select(db.files.ALL)
> for row in rows:
> f = row.file_blob
> email_addresses = f.split('\n')
> for email_address in email_addresses:
> taskqueue.add(url='/init/default/sendmail', params=dict
> (to=email_address, subject='Hello ' + email_address, body='this is a
> message!'))
> return dict(message=T('mail was queued'))
>
> def sendmail():
> mail.send_mail(
> '[email protected]', # needs to be from settings
> request.vars['to'],
> request.vars['subject'],
> request.vars['body'])
>
> but my sendmail function never gets called. Everything seems fine up
> through the task queue, but no callback.
>
> Thanks,
> David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---