1 """
2 VOSI renderers.
3
4 These are really three different renderers for each service. IVOA wants
5 it this way (in effect, since they are supposed to be three different
6 capabilities).
7 """
8
9
10
11
12
13
14
15 from nevow import inevow
16 from nevow import rend
17 from twisted.internet import threads
18
19 from gavo import base
20 from gavo import registry
21 from gavo import svcs
22 from gavo import utils
23 from gavo.base import meta
24 from gavo.registry import capabilities
25 from gavo.registry import tableset
26 from gavo.registry.model import VS
27 from gavo.utils.stanxml import Element, registerPrefix, schemaURL, xsiPrefix
28 from gavo.utils.stanxml import write as writeXML
29 from gavo.web import grend
30
31
32 registerPrefix("avl", "http://www.ivoa.net/xml/VOSIAvailability/v1.0",
33 schemaURL("VOSIAvailability-v1.0.xsd"))
34 registerPrefix("cap", "http://www.ivoa.net/xml/VOSICapabilities/v1.0",
35 schemaURL("VOSICapabilities-v1.0.xsd"))
36 registerPrefix("vtm", "http://www.ivoa.net/xml/VOSITables/v1.0",
37 schemaURL("VOSITables-v1.0.xsd"))
38
39
40
42 """An abstract base for renderers handling VOSI requests.
43
44 All of these return some sort of XML and are legal on all services.
45
46 The actual documents returned are defined in _getTree(request)->deferred
47 firing stanxml.
48 """
49 checkedRenderer = False
50
52 request = inevow.IRequest(ctx)
53 request.setHeader("content-type", "text/xml")
54 return threads.deferToThread(self._getTree, request
55 ).addCallback(self._shipout, ctx
56 ).addErrback(self._sendError, request)
57
59 return utils.xmlrender(response,
60 "<?xml-stylesheet href='/static/xsl/vosi.xsl' type='text/xsl'?>")
61
63 request.setResponseCode(500)
64 request.setHeader("content-type", "text/plain")
65 request.write("Sorry -- we're experiencing severe problems.\n")
66 request.write("If you are reading this, you can help us by\n")
67 request.write("reporting the following to gavo@ari.uni-heidelberg.de:\n")
68 failure.printBriefTraceback(file=request)
69 return ""
70
72 raise ValueError("_getTree has not been overridden.")
73
74
75
76
77
79 """The container for elements from the VOSI availability schema.
80 """
83
88 - class downAt(AVLElement): pass
89 - class backAt(AVLElement): pass
90 - class note(AVLElement): pass
91
92
94 """The container for element from the VOSI capabilities schema.
95 """
98
101
102
104 """The container for element from the VOSI tableset schema.
105 """
108
111
112 - class table(VTMElement, VS.table):
115
116
117
118 SF = meta.stanFactory
119
120 _availabilityBuilder = meta.ModelBasedBuilder([
121 ('available', SF(AVL.available)),
122 ('upSince', SF(AVL.upSince)),
123 ('_scheduledDowntime', SF(AVL.downAt)),
124 ('backAt', SF(AVL.backAt)),
125 ('availability_note', SF(AVL.note)),
126 ])
127
128
129
130
132 """A renderer for a VOSI availability endpoint.
133
134 An endpoint with this renderer is automatically registered for
135 every service. The answers can be configured using the admin
136 renderer.
137 """
138 name = "availability"
139
144
145
147 """A renderer for a VOSI capability endpoint.
148
149 An endpoint with this renderer is automatically registered for
150 every service. The responses contain information on what renderers
151 ("interfaces") are available for a service and what properties they have.
152 """
153 name = "capabilities"
154
166
167
169 """A resource building a VOSI tableset for a single table.
170
171 This is returned as a child resource of VOSITablesetRenderer.
172 """
174 self.tableDef = tableDef
175
177 return threads.deferToThread(self._getTree, ctx
178 ).addCallback(self._renderTree, ctx)
179
183
185 request = inevow.IRequest(ctx)
186 request.setHeader("content-type", "text/xml")
187 writeXML(tree, request)
188 return ""
189
190
192 """A renderer for a VOSI table metadata endpoint.
193
194 An endpoint with this renderer is automatically registered for
195 every service. The responses contain information on the tables
196 exposed by a given service.
197 """
198 name = "tableMetadata"
199
207
223