gavo.protocols.dlasync module

A UWS-based interface to datalink.

TODO: There’s quite a bit of parallel between this and useruws. This should probably be reformulated along the lines of useruws.

class gavo.protocols.dlasync.DLJob(props, uws, writable=False)[source]

Bases: UWSJobWithWD

a UWS job performing some datalink data preparation.

In addition to UWS parameters, it has

  • serviceid – the fully qualified id of the service that will process the request

  • datalinkargs – the parameters (in request.args form) of the datalink request.

class gavo.protocols.dlasync.DLTransitions[source]

Bases: ProcessBasedUWSTransitions

The transition function for datalink jobs.

getCommandLine(wjob)[source]
queueJob(newState, wjob, ignored)[source]

puts a job on the queue.

class gavo.protocols.dlasync.DLUWS[source]

Bases: UWS

the worker system for datalink jobs.

property baseURL
getURLForId(jobId)[source]

returns a fully qualified URL for the job with jobId.

jobdocPreamble = "<?xml-stylesheet href='/static/xsl/dlasync-job-to-html.xsl' type='text/xsl'?>"
joblistPreamble = "<?xml-stylesheet href='/static/xsl/dlasync-joblist-to-html.xsl' type='text/xsl'?>"
property parameterGrammar

A grammar for web inputs.

The source tokens for context grammars are dictionaries; these are either typed dictionaries from gavo.formal, where the values usually are atomic, or, preferably, the dictionaries of lists from request.strargs.

ContextGrammars never yield rows, so they’re probably fairly useless in normal circumstances.

In normal usage, they just yield a single parameter row, corresponding to the source dictionary possibly completed with defaults, where non-requried input keys get None defaults where not given. Missing required parameters yield errors.

This parameter row honors the multiplicity specification, i.e., single or forced-single are just values, multiple are lists. The content are parsed values (using the InputKeys’ parsers).

Since most VO protocols require case-insensitive matching of parameter names, matching of input key names and the keys of the input dictionary is attempted first literally, then disregarding case.

Since ContextGrammars can be parents of inputKeys and thus are a bit table-like, they can also carry metadata.

class gavo.protocols.dlasync.WritingFakeRequest(destFile)[source]

Bases: FakeRequest

a simulator for actual t.w requests.

We want this here as we’re rendering to a UWS result file with the same code that renders to web requests.

One could probably go a lot simpler than testtricks.FakeRequest, but since the code is there anyway, it probably doesn’t hurt to use it in case we want to do fancier things in the future.

The one thing I have to change vs. testtricks is that we want to write to files.

finish()[source]

Record that the request is finished and callback and L{Deferred}s waiting for notification of this.

write(stuff)[source]

Write data to the transport (if not responding to a HEAD request).

@param data: A string to write to the response. @type data: L{bytes}

gavo.protocols.dlasync.main()[source]
gavo.protocols.dlasync.parseCommandLine()[source]
gavo.protocols.dlasync.writeResultTo(page, destFile)[source]

arranges for the result of rendering the twisted.web resource to be written to destFile.

This uses a very simple simulation of t.w rendering, so a few tricks are possible. Also, it actually runs a reactor to do its magic.

Do not run this in a running DaCHS server; it has its own reactor running. This is only for dachs dlrun code.

TODO: There’s proabably code for this in t.w.