Module products
source code
Products and a core turning accrefs into lists of products.
There is a substantial overlap between what's going on there and
datalink (and datalink uses some of the products mentioned here). The
cutouts and scale things here shouldn't be developed on, all this should
move towards datalink. Meanwhile, we still have siapCutoutCore and
friends that relies on the mess here, so all this is going to remain for
the forseeable future. Just don't extend it.
The "user-visible" part are just accrefs, as modelled by the
RAccref -- they can contain instructions for cutouts or scaling, hence
the additional structure.
Using the product table and some logic in this module, such accrefs
are turned into subclasses of ProductBase.
These have mime types and know how to generate their data through
their synchronous iterData methods. They must also work as nevow
resources and thus have implement asynchronuous renderHTTP(ctx) methods.
It's a bit unfortunate that we thus depend on nevow here, but we'd have
to reimplement quite a bit of it if we don't, and for now it doesn't seem
we'll support a different framework in the forseeable future.
|
makePreviewFromFITS(product)
returns image/jpeg bytes for a preview of a product spitting out a 2D
FITS. |
source code
|
|
|
makePreviewWithPIL(product)
returns image/jpeg bytes for a preview of the PIL-readable product. |
source code
|
|
|
|
|
|
|
unquoteProductKey(key)
reverses quoteProductKey. |
source code
|
|
|
getProductColumns(colSeq)
returns the columns within colSeq that contain product links of some
sort. |
source code
|
|
|
|
|
|
|
|
|
PREVIEW_SIZE = 200
|
|
PRODUCTS_TDID = ' //products#products '
|
|
REMOTE_URL_PATTERN = re.compile(r'( https? | ftp) ://')
|
|
PRODUCT_CLASSES = [ <class 'gavo.protocols.products.RemotePrevi...
|
|
__package__ = ' gavo.protocols '
|
returns image/jpeg bytes containing a preview of product.
This only works for a select subset of products. You're usually
better off using static previews.
|
getProductForRAccref(rAccref,
authGroups=None)
| source code
|
returns a product for a RAccref.
This tries, in sequence, to make a product using each element of
PRODUCT_CLASSES' fromRAccref method. If nothing succeeds, it will return
an InvalidProduct.
If rAccref is a string, the function makes a real RAccref through
RAccref's fromString method from it.
|
returns key as getproduct URL-part.
If ``key`` is a string, it is quoted as a naked accref so it's usable
as the path part of an URL. If it's an ``RAccref``, it is just
stringified. The result is something that can be used after getproduct in
URLs in any case.
- Decorators:
|
makeProductLink(key,
withHost=True,
useHost=None)
| source code
|
returns the URL at which a product can be retrieved.
key can be an accref string or an RAccref
- Decorators:
|
turns a string val into a product link.
This is faily ad-hoc: if val looks like a URL, it is left alone, else
turn it into a link into our product service (which means val must be an
accref into the product table).
|
PRODUCT_CLASSES
- Value:
[ <class 'gavo.protocols.products.RemotePreview'>,
<class 'gavo.protocols.products.StaticPreview'>,
<class 'gavo.protocols.products.NonExistingProduct'>,
<class 'gavo.protocols.products.UnauthorizedProduct'>,
<class 'gavo.protocols.products.RemoteProduct'>,
<class 'gavo.protocols.products.CutoutProduct'>,
<class 'gavo.protocols.products.ScaledFITSProduct'>,
<class 'gavo.protocols.products.FileProduct'>]
|
|