gavo.registry.oaiinter module

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.

class gavo.registry.oaiinter.RegistryCore(parent, **kwargs)[source]

Bases: Core, RestrictionMixin

is a core processing OAI requests.

Its signature requires a single input key containing the complete args from the incoming request. This is necessary to satisfy the requirement of raising errors on duplicate arguments.

It returns an ElementTree.

This core is intended to work the the RegistryRenderer.

attrSeq = [<gavo.base.parsecontext.IdAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.complexattrs.PropertyAttribute object>, <gavo.rscdef.common.RDAttribute object>]
builders = {'GetRecord': ({'ivo_vor': <function getVOGetRecordElement>, 'oai_dc': <function getDCGetRecordElement>}, <function RegistryCore.<lambda>>), 'Identify': (<function getIdentifyElement>, <function RegistryCore.<lambda>>), 'ListIdentifiers': ({'ivo_vor': <function getListIdentifiersElement>, 'oai_dc': <function getListIdentifiersElement>}, <function RegistryCore.<lambda>>), 'ListMetadataFormats': (<function getListMetadataFormatsElement>, <function _makeArgsForListMetadataFormats>), 'ListRecords': ({'ivo_vor': <function getVOListRecordsElement>, 'oai_dc': <function getDCListRecordsElement>}, <function RegistryCore.<lambda>>), 'ListSets': (<function getListSetsElement>, <function RegistryCore.<lambda>>)}
clearProperty(name)
completedCallbacks = []
getFullId()
getProperty(name, default=<Undefined>)
hasProperty(name)
inputTableXML = '\n\t\t<inputTable id="_pubregInput">\n\t\t\t<inputKey name="args" type="raw"\n\t\t\t\tmultiplicity="single"\n\t\t\t\tdescription="The raw dictionary of input parameters"/>\n\t\t</inputTable>\n\t\t'
managedAttrs = {'id': <gavo.base.parsecontext.IdAttribute object>, 'inputTable': <gavo.base.complexattrs.StructAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'outputTable': <gavo.base.complexattrs.StructAttribute object>, 'properties': <gavo.base.complexattrs.PropertyAttribute object>, 'property': <gavo.base.complexattrs.PropertyAttribute object>, 'rd': <gavo.rscdef.common.RDAttribute object>}
name_ = 'registryCore'
outputTableXML = '<outputTable/>'
property rd
run(service, inputTable, queryMeta)[source]

returns an ElementTree containing a OAI-PMH response for the query described by pars.

runWithPMHDict(args)[source]
setProperty(name, value)
gavo.registry.oaiinter.checkPars(pars, required, optional=[], ignored={'maxRecords', 'verb'})[source]

raises exceptions for missing or illegal parameters.

gavo.registry.oaiinter.dispatchOnPrefix(pars, contentMakers)[source]

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.

gavo.registry.oaiinter.getMatchingResobs(pars)[source]

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

See getMatchingRestups for details.

gavo.registry.oaiinter.getMatchingRestups(pars)[source]

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

See getMatchingRows for details on pars.

gavo.registry.oaiinter.getMatchingRows(pars, rscTableDef, getSetFilter)[source]

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

gavo.registry.oaiinter.getResponseHeaders(pars)[source]

returns the OAI response header for a query with pars.

gavo.registry.oaiinter.makeResumptionToken(pars, nextOffset)[source]

return a resumptionToken element for resuming the query in pars at nextOffset.

gavo.registry.oaiinter.parseResumptionToken(pars)[source]

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.

gavo.registry.oaiinter.runPMH(pars, builders)[source]

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.