Home | Trees | Indices | Help |
|
---|
|
1 """ 2 Code dealing with product (i.e., fits file) delivery. 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 nevow import inevow 12 13 from gavo import base 14 from gavo import svcs 15 from gavo.protocols import products 16 from gavo.web import grend 17 1820 """The renderer used for delivering products. 21 22 This will only work with a ProductCore since the resulting 23 data set has to contain products.Resources. Thus, you probably 24 will not use this in user RDs. 25 """ 26 name = "get" 27 pathFromSegments = "" 287930 request = inevow.IRequest(ctx) 31 try: 32 data = {"accref": 33 products.RAccref.fromRequest(self.pathFromSegments, request)} 34 except base.NotFoundError: 35 raise base.ui.logOldExc(svcs.UnknownURI("No product specified")) 36 37 # deferring here and going to all the trouble of running a core 38 # is probably overkill; currently, the main thing that'd require 39 # handwork is figuring out authentication in parallel with what 40 # needs to be done for tar files. We should do better, indded. 41 return self.runServiceWithFormalData(data, ctx 42 ).addCallback(self._deliver, ctx)4345 doPreview = result.queryMeta.ctxArgs.get("preview") 46 # SvcResult madness; clean up SvcResult and remove this. 47 result = getattr(result, "original", result) 48 product = result[0] 49 request = inevow.IRequest(ctx) 50 51 # TODO: figure out a good way to see whether what we've got already is a 52 # preview. 53 if doPreview and not "Preview" in product.__class__.__name__: 54 return products.PreviewCacheManager.getPreviewFor(product 55 ).addCallback(self._deliverPreview, product, request 56 ).addErrback(self._deliverPreviewFailure, request) 57 58 else: 59 return product6062 previewMime = product.pr["preview_mime"] or "image/jpeg" 63 request.setHeader("content-type", str(previewMime)) 64 request.setHeader("content-length", len(content)) 65 return content6668 failure.printTraceback() 69 data = "Not an image (preview generation failed, please report)" 70 request.setResponseCode(500) 71 request.setHeader("content-type", "text/plain") 72 request.setHeader("content-length", str(len(data))) 73 return data74
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |