Source code for gavo.registry.common

"""
Common code and definitions for registry support.
"""

#c Copyright 2008-2023, the GAVO project <gavo@ari.uni-heidelberg.de>
#c
#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"


METADATA_PREFIXES = [
# (prefix, schema-location, namespace)
	("oai_dc", stanxml.schemaURL("OAI-PMH.xsd"),
		"http://www.openarchives.org/OAI/2.0/oai_dc/"),
	("ivo_vor", stanxml.schemaURL("VOResource-v1.0.xsd"),
		"http://www.ivoa.net/xml/RegistryInterface/v1.0"),
]


[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", ]