Package gavo :: Package registry :: Module oaiinter
[frames] | no frames]

Module oaiinter

source code

The standard OAI interface.

In this module the core handling the OAI requests and the top-level handlers for the verbs are defined.

The top-level handlers are all called run_<verb> -- any such function is web-callable.

Classes
  RegistryCore
is a core processing OAI requests.
Functions
 
runPMH(pars, builders)
runs the OAI-PMH handling function.
source code
 
makeResumptionToken(pars, nextOffset)
return a resumptionToken element for resuming the query in pars at nextOffset.
source code
 
parseResumptionToken(pars)
returns a a dict realPars for an OAI-PMH parameter dictionary pars.
source code
 
checkPars(pars, required, optional=[], ignored=set(['maxRecords', 'verb']))
raises exceptions for missing or illegal parameters.
source code
 
getResponseHeaders(pars)
returns the OAI response header for a query with pars.
source code
 
dispatchOnPrefix(pars, contentMakers)
returns a resource factory depending on the metadataPrefix in pars.
source code
 
getMatchingRows(pars, rscTableDef, getSetFilter)
returns rows in rscTableDef matching the OAI parameters pars.
source code
 
getMatchingRestups(pars)
returns a list of res tuples matching the OAI query arguments pars.
source code
 
getMatchingResobs(pars)
returns a list of res objects matching the OAI-PMH pars.
source code
Variables
  __package__ = 'gavo.registry'
Function Details

runPMH(pars, builders)

source code 

runs the OAI-PMH handling function.

builders is a mapping of verbs to tuples of (oai_dc-generating-function, ivo_vor-generating-function, argument-building-function).

The argument-building function takes the OAI-PMH parameter dictionary (that's already validated for mandatory and optional arguments) and returns a tuple that is then passed on to the generating functions.

Those must returns stanxml for inclusion in an OAI.PMH element. The response header is generated by this function.

parseResumptionToken(pars)

source code 

returns a a dict realPars for an OAI-PMH parameter dictionary pars.

If we believe that the registry has changed since rawToken's timestamp, we raise a BadResumptionToken exception. This is based on gavo pub reloading the //services RD after publication. Not perfect, but probably adequate.

Note that newPars will contain resumptionToken again, but as an offset to the query executed.

dispatchOnPrefix(pars, contentMakers)

source code 

returns a resource factory depending on the metadataPrefix in pars.

contentMakers is one of the dictionaries called "verb" in builders below.

Invalid metadataPrefixes are detected here and lead to exceptions.

getMatchingRows(pars, rscTableDef, getSetFilter)

source code 

returns rows in rscTableDef matching the OAI parameters pars.

The last element of the list could be an OAI.resumptionToken element. pars is a dictionary mapping any of the following keys to values:

  • from
  • until -- these give a range for which changed records are being returned
  • set -- maps to a sequence of set names to be matched.
  • resumptionToken -- some magic value (see OAI.resumptionToken)
  • maxRecords -- an integer literal that specifies the maximum number of records returned, defaulting to [ivoa]oaipmhPageSize

maxRecords is not part of OAI-PMH; it is used internally to turn paging on when we think it's a good idea, and for testing.

rscTableDef has to be a table with a column recTimestamp giving the resource record's updated time.

getSetFilter(pars, fillers) is a function receiving the PMH parameters dictionary and a dictionary of query fillers and returning, as appropriate, a condition that implements any conditions on sets within pars

getMatchingRestups(pars)

source code 

returns a list of res tuples matching the OAI query arguments pars.

See getMatchingRows for details on pars.

getMatchingResobs(pars)

source code 

returns a list of res objects matching the OAI-PMH pars.

See getMatchingRestups for details.