tipfy.ext.taskqueue¶
This module provides utilities to work with google.appengine.api.labs.taskqueue.
See the extension wiki page.
Deferred handler replacement¶
- class tipfy.ext.taskqueue.DeferredHandler(app, request)¶
A handler class that processes deferred tasks invocations, mirrored from google.appengine.ext.deferred. Map to this handler if you want to use the deferred package running on the same WSGI application as other handlers. Tipfy utilities will then be available to be used in the deferred function.
The setup for app.yaml is:
- url: /_ah/queue/deferred script: main.py login: admin
The URL rule for urls.py is:
Rule('/_ah/queue/deferred', endpoint='tasks/deferred', handler='tipfy.ext.taskqueue:DeferredHandler')
Model iterator¶
- class tipfy.ext.taskqueue.Mapper¶
A base class to process all entities in single datastore kind, using the task queue. On each request, a batch of entities is processed and a new task is added to process the next batch.
For example, to delete all ‘MyModel’ records:
from tipfy.ext.taskqueue import Mapper from mymodels import myModel class MyModelMapper(EntityTaskHandler): model = MyModel def map(self, entity): # Add the entity to the list of entities to be deleted. return ([], [entity]) mapper = MyModelMapper() deferred.defer(mapper.run)
The setup for app.yaml is:
- url: /_ah/queue/deferred script: main.py login: admin
The URL rule for urls.py is:
Rule('/_ah/queue/deferred', endpoint='tasks/deferred', handler='tipfy.ext.tasks:DeferredHandler')
This class derives from http://code.google.com/appengine/articles/deferred.html
