View source on GitHub |
A handler class for processesing deferred invocations.
Inherits From: expected_type
Methods
post
post(
environ
)
Default behavior for POST requests to the deferred endpoint.
If the Deferred API has been enabled, this function is automatically called after 'deferred.defer()' is used to defer a task. Behind the scenes, the TaskQueue service calls the default Deferred endpoint '/_ah/queue/deferred', which is routed to this function.
If deferred.defer() is passed a custom '_url' parameter, POST requests to the custom endpoint needs to be handled by the app. To replicate the default behavior of executing a deferred task, this function can be called by the custom endpoint handler, and passed the WSGI 'environ' dictionary of the POST request.
Args | |
---|---|
environ
|
a WSGI dict describing the HTTP request (See PEP 333) |
Returns | |
---|---|
response
|
a string containing body of the response |
status
|
HTTP status code of enum type http.HTTPStatus |
headers
|
a dict containing response headers |
run_from_request
run_from_request(
environ
)
Executes deferred tasks after verifying the caller.
This function assumes that the WSGI environ dict originated from a POST request by the GAE TaskQueue service. It checks the caller IP and request headers to verify the caller. Args: environ: a WSGI dict describing the HTTP request (See PEP 333). Returns: response: a string containing body of the response status: HTTP status code of enum type http.HTTPStatus headers: a dict containing response headers Raises: PermanentTaskFailure if an error occurred during unpickling the task.
__call__
__call__(
environ, start_response
)
WSGI app callable to handle POST requests to the deferred endpoint.
This function allows the 'Handler' class to behave like a WSGI app for handling Deferred task execution.
If the parent WSGI app is required to handle multiple kinds of requests, a dispatcher (compliant with the app's Web Framework) can be used to route an endpoint/URL to be handled by this callable.
Args | |
---|---|
environ
|
a WSGI dict describing the HTTP request (See PEP 333) |
start_response
|
callable (See PEP 3333) |
Returns | |
---|---|
list of bytes response |