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

Class PreviewCacheManager

source code

object --+
         |
        PreviewCacheManager

is a class that manages the preview cache.

It's really the class that manages it, so don't bother creating instances.

The normal operation is that you pass the product you want a preview to getPreviewFor. If a cached preview already exists, you get back its content (the mime type must be taken from the products table).

If the file does not exist yet, some internal magic tries to come up with a preview and determines whether it should be cached, in which case it does so provided a preview has been generated successfully.

A cache file is touched when it is used, so you can clean up rarely used cache files by deleting all files in the preview cache older than some limit.

Instance Methods

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
getCacheName(cls, accref)
returns the full path a preview for accref is be stored under.
source code
 
getCachedPreviewPath(cls, accref)
returns the path to a cached preview if it exists, None otherwise.
source code
 
saveToCache(self, data, cacheName) source code
 
getPreviewFor(cls, product)
returns a deferred firing the data for a preview.
source code
Class Variables
  cachePath = u'/home/msdemlei/gavo/web/previewcache'
Properties

Inherited from object: __class__