1 """
2 Renderers and helpers for asynchronous services.
3
4 For TAP (which was the first prototype of these), there's a separate
5 module using some of this; on the long run, it should probably be
6 integrated here.
7 """
8
9
10
11
12
13
14
15 from nevow import inevow
16 from nevow import rend
17 from twisted.internet import defer
18
19 from gavo import base
20 from gavo import svcs
21 from gavo import utils
22 from gavo.protocols import uws
23 from gavo.protocols import uwsactions
27 """a redirection for UWS (i.e., 303).
28
29 The DC-global redirects use a 302 status, munge redirection URLs, and
30 we don't want any HTML payload here anyway.
31
32 The locations used here are relative to baseURL, which essentially
33 has to be the the full absolute URL of the endpoint (i.e.,
34 service/renderer). As a special service, for TAP async is being
35 added as long as the renderer isn't fixed to not do dispatching.
36 """
38
39
40
41 if baseURL.endswith("tap"):
42 baseURL = baseURL+"/async"
43
44 if location:
45 if location.startswith("http://") or location.startswith("https://"):
46 self.location = str(location)
47 else:
48 self.location = str(
49 "%s/%s"%(baseURL, location))
50 else:
51 self.location = str(baseURL)
52
54 req = inevow.IRequest(ctx)
55 req.code = 303
56 req.setHeader("location", self.location)
57 req.setHeader("content-type", "text/plain")
58 req.write("Go here: %s\n"%self.location)
59 return ""
60
63 """is a rend.Page with behaviour depending on the HTTP method.
64 """
65 - def __init__(self, workerSystem, renderer, service):
69
72
74 request = inevow.IRequest(ctx)
75 handlingMethod = getattr(self, "_do"+request.method, self._doBADMETHOD)
76 return defer.maybeDeferred(handlingMethod, ctx, request
77 ).addCallback(self._deliverResult, request
78 ).addErrback(self._deliverError, request)
79
91
94 """The web resource corresponding to async root.
95
96 GET yields a job list, POST creates a job.
97
98 There's an extra hack not in UWS: if get with something like
99 dachs_authenticate=anything and haven't passed a user, this will ask
100 for credentials.
101 """
102 @utils.memoized
129
130 - def _doGET(self, ctx, request):
144
145 - def _doPOST(self, ctx, request):
149
151 request.setHeader("content-type", "text/xml")
152 return res
153
156 """The web resource corresponding to async requests for jobs.
157 """
158 - def __init__(self, workerSystem, renderer, service, segments):
161
169
174
181
188