Package gavo :: Package protocols :: Module dali
[frames] | no frames]

Module dali

source code

Common code supporting functionality described in DALI.

Classes
  URLUpload
a somewhat FieldStorage-compatible facade to an upload coming from a URL.
Functions
 
getUploadKeyFor(inputKey)
returns an input key for file items in "PQL".
source code
 
parseUploadString(uploadString)
returns resourceName, uploadSource from a DALI upload string.
source code
 
iterUploads(request)
iterates over DALI uploads in request.
source code
 
mangleUploads(request)
manipulates request to turn DALI UPLOADs into what nevow formal produces for file uploads.
source code
 
writeUploadBytesTo(request, destDir)
writes a file corresponding to a DALI upload to destDir.
source code
Variables
  __package__ = 'gavo.protocols'
Function Details

getUploadKeyFor(inputKey)

source code 

returns an input key for file items in "PQL".

This is actually specified by DALI. In that scheme, the parameter is always called UPLOAD (there can thus only be one such parameter, but it can be present multiple times if necessary, except we've not figured out how to do the description right in that case).

It contains a comma-separated pair of (key,source) pairs, where source is a URL; there's a special scheme param: for referring to inline uploads by their name.

This is used exclusively for metadata generation, and there's special code to handle it there. There's also special code in inputdef.ContextGrammar to magcially make UPLOAD into the file parameters we use within DaCHS. Sigh.

iterUploads(request)

source code 

iterates over DALI uploads in request.

This yields pairs of (file name, file object), where file name is the file name requested (sanitized to have no slashes and non-ASCII). The UPLOAD and inline-file keys are removed from request's args member. file object is a cgi-style thing with file, filename, etc. attributes.

mangleUploads(request)

source code 

manipulates request to turn DALI UPLOADs into what nevow formal produces for file uploads.

These are as in normal CGI: uploads are under "their names" (with DALI uploads, the resource names), with values being pairs of some name and a FieldStorage-compatible thing having name, filename, value, file, type, type_options, and headers.

ArgDict is manipulated in place.

writeUploadBytesTo(request, destDir)

source code 

writes a file corresponding to a DALI upload to destDir.

For the sake uws.UploadParameter, we return the names of the files we've been creating.