gavo.web.asyncrender module¶
Renderers and helpers for asynchronous services.
For TAP (which was the first prototype of these), there’s a separate module using some of this; on the long run, it should probably be integrated here.
- class gavo.web.asyncrender.AsyncRendererBase(request, service)[source]¶
Bases:
ServiceBasedPage
An abstract renderer for things running in a UWS.
To make these concrete, they need a name and a workerSystem attribute.
- getChild(name, request)[source]¶
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- parameterStyle = 'pql'¶
- render(request)[source]¶
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class gavo.web.asyncrender.DALIAsyncRenderer(request, service)[source]¶
Bases:
AsyncRendererBase
A renderer speaking UWS.
This is for asynchronous execution of larger jobs. This is what is executed by the async renderer. It requests the worker system required from the service, which in turn obtains it from the core; these must hence cooperate with this to allow async operation.
See `Custom UWSes`_ for how to use this with your own cores.
- aliases = frozenset({'uws.xml'})¶
- name = 'async'¶
- property workerSystem¶
- class gavo.web.asyncrender.DatalinkAsyncRenderer(request, service)[source]¶
Bases:
AsyncRendererBase
A renderer for asynchronous datalink.
- name = 'dlasync'¶
- render(request)[source]¶
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- workerSystem = <gavo.protocols.dlasync.DLUWS object>¶
- class gavo.web.asyncrender.JobResource(workerSystem, renderer, service, segments)[source]¶
Bases:
UWSResource
The web resource corresponding to async requests for jobs.
This currently uses a custom hack for resource resolution and method dispatch. Let’s move it to using twisted resources one day.
- render(request)[source]¶
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class gavo.web.asyncrender.JoblistResource(workerSystem, renderer, service)[source]¶
Bases:
UWSResource
The web resource corresponding to async root.
GET yields a job list, POST creates a job.
There’s an extra hack not in UWS: if get with something like dachs_authenticate=anything and haven’t passed a user, this will ask for credentials.
- class gavo.web.asyncrender.UWSResource(workerSystem, renderer, service)[source]¶
Bases:
Resource
a resource dealing with a UWS.
It is constructed with a worker system, a concrete renderer, and the service that executes requests.
It also delivers errors in UWS (well, TAP, actually) style.
- render(request)[source]¶
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- gavo.web.asyncrender.getAsyncResource(request, workerSystem, renderer, service, firstSegment)[source]¶
returns a UWS-compliant resource for request.
Note: This expects that the renderer has already called uws.prepareRequest.
- gavo.web.asyncrender.redirectUWS(baseURL, location)[source]¶
raises an UWS-compatible (303) redirection.
baseURL and location and then just raise svc.Found The locations used here are relative to baseURL, which essentially has to be the the full absolute URL of the endpoint (i.e., service/renderer). As a special service, for TAP async is being added as long as the renderer isn’t fixed to not do dispatching.
This essentially just mogrifies SeeOther exceptions rendered elsewhere. It should therefore go at some point (probably when TAP uses the async renderer).