Package gavo :: Package protocols :: Module products
[frames] | no frames]

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.

Classes
  PreviewCacheManager
is a class that manages the preview cache.
  ProductBase
A base class for products returned by the product core.
  FileProduct
A product corresponding to a local file.
  StaticPreview
A product that's a cached or pre-computed preview.
  RemoteProduct
A class for products at remote sites, given by their URL.
  RemotePreview
A preview that's on a remote server.
  UnauthorizedProduct
A local file that is not delivered to the current client.
  NonExistingProduct
A local file that went away.
  InvalidProduct
An invalid file.
  CutoutProduct
A class representing cutouts from FITS files.
  ScaledFITSProduct
A class representing a scaled FITS file.
  ProductCore
A core retrieving paths and/or data from the product table.
  RAccref
A product key including possible modifiers.
Functions
 
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
 
computePreviewFor(product)
returns image/jpeg bytes containing a preview of product.
source code
 
getProductForRAccref(rAccref, authGroups=None)
returns a product for a RAccref.
source code
 
unquoteProductKey(key)
reverses quoteProductKey.
source code
 
getProductColumns(colSeq)
returns the columns within colSeq that contain product links of some sort.
source code
 
quoteProductKey(key)
returns key as getproduct URL-part.
source code
 
makeProductLink(key, withHost=True, useHost=None)
returns the URL at which a product can be retrieved.
source code
 
formatProductLink(val, useHost)
turns a string val into a product link.
source code
Variables
  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'
Function Details

computePreviewFor(product)

source code 

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.

quoteProductKey(key)

source code 

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:
  • @utils.document

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:
  • @utils.document

formatProductLink(val, useHost)

source code 

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).


Variables Details

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'>]