| Home | Trees | Indices | Help |
|
|---|
|
|
1 """
2 Common code and definitions for registry support.
3 """
4
5 #c Copyright 2008-2019, the GAVO project
6 #c
7 #c This program is free software, covered by the GNU GPL. See the
8 #c COPYING file in the source distribution.
9
10
11 from gavo import base
12 from gavo import utils
13 from gavo.utils import stanxml
14
15
16 SERVICELIST_ID = "__system__/services"
17
18
19 METADATA_PREFIXES = [
20 # (prefix, schema-location, namespace)
21 ("oai_dc", stanxml.schemaURL("OAI-PMH.xsd"),
22 "http://www.openarchives.org/OAI/2.0/oai_dc/"),
23 ("ivo_vor", stanxml.schemaURL("VOResource-v1.0.xsd"),
24 "http://www.ivoa.net/xml/RegistryInterface/v1.0"),
25 ]
26
27
31
40
41
44
45
48
49
51 res = base.getMetaText(resob, "resType", default=None)
52 if res is None:
53 res = resob.resType
54 return res
55
56
58 """returns a list of RD ids that are need for the generation of RRs
59 from rdId.
60 """
61 if connection is None:
62 with base.getTableConn() as conn:
63 return getDependencies(rdId, conn)
64
65 return [r[0] for r in
66 connection.query(getServicesRD().getById("res_dependencies")
67 .getSimpleQuery(["prereq"], "rd=%(rd)s"), {"rd": rdId})]
68
69
71 """A mixin providing computers for dateUpdated and datetimeUpdated.
72
73 The trouble is that we need this in various formats. Classes
74 mixing this in may give a dateUpdated attribute (a datetime.datetime)
75 that is used to compute both meta elements.
76
77 If any of them is overridden manually, the other is computed from
78 the one given.
79 """
81 dt = getattr(self, "dateUpdated", None)
82 if dt is None:
83 raise base.NoMetaKey(key, carrier=self)
84 return dt.strftime(format)
85
87 if "datetimeUpdated" in self.meta_:
88 return str(self.meta_["datetimeUpdated"])[:8]
89 return self.__getDatetimeMeta("dateUpdated", "%Y-%m-%d")
90
92 if "dateUpdated" in self.meta_:
93 return str(self.meta_["dateUpdated"])+"T00:00:00"
94 return self.__getDatetimeMeta("dateUpdated", utils.isoTimestampFmtNoTZ)
95
96
97 __all__ = ["SERVICELIST_ID", "METADATA_PREFIXES",
98
99 "getResType", "getServicesRD", "getRegistryService", "getDependencies",
100
101 "DateUpdatedMixin",
102
103 "OAIError", "BadArgument", "BadResumptionToken", "BadVerb",
104 "CannotDisseminateFormat", "IdDoesNotExist",
105 "NoMetadataFormats", "NoSetHierarchy",
106 "NoRecordsMatch",
107 ]
108
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |