Source code for gavo.registry.common

Common code and definitions for registry support.

#c Copyright 2008-2023, the GAVO project <>
#c This program is free software, covered by the GNU GPL.  See the
#c COPYING file in the source distribution.

from gavo import base
from gavo.utils import stanxml

SERVICELIST_ID = "__system__/services"

# (prefix, schema-location, namespace)
	("oai_dc", stanxml.schemaURL("OAI-PMH.xsd"),
	("ivo_vor", stanxml.schemaURL("VOResource-v1.0.xsd"),

[docs]class OAIError(base.Error): """is one of the standard OAI errors. """
[docs]class BadArgument(OAIError): pass
[docs]class BadResumptionToken(OAIError): pass
[docs]class BadVerb(OAIError): pass
[docs]class CannotDisseminateFormat(OAIError): pass
[docs]class IdDoesNotExist(OAIError): pass
[docs]class NoMetadataFormats(OAIError): pass
[docs]class NoSetHierarchy(OAIError): pass
[docs]class NoRecordsMatch(OAIError): pass
[docs]def getServicesRD(): return base.caches.getRD(SERVICELIST_ID)
[docs]def getResType(resob): res = base.getMetaText(resob, "resType", default=None) if res is None: res = resob.resType return res
[docs]def getDependencies(rdId, connection=None): """returns a list of RD ids that are need for the generation of RRs from rdId. """ if connection is None: with base.getTableConn() as conn: return getDependencies(rdId, conn) return [r[0] for r in connection.query(getServicesRD().getById("res_dependencies") .getSimpleQuery(["prereq"], "rd=%(rd)s"), {"rd": rdId})]
__all__ = ["SERVICELIST_ID", "METADATA_PREFIXES", "getResType", "getServicesRD", "getDependencies", "OAIError", "BadArgument", "BadResumptionToken", "BadVerb", "CannotDisseminateFormat", "IdDoesNotExist", "NoMetadataFormats", "NoSetHierarchy", "NoRecordsMatch", ]