Core Functionality

class acrylamid.core.Memory

A callable dictionary object described at acrylamid.helpers.memoize().

class acrylamid.core.cache

A cache that stores all intermediates of an entry zlib-compressed on file system. Inspired from werkzeug.contrib.cache, but heavily modified to fit our needs.

Terminology: A cache object is a pickled dictionary into a single file. An intermediate (object) is a key/value pair that we store into a cache object. An intermediate is the content of an entry that is the same for a chain of filters used in different views.

cache is designed as global singleton and should not be constructed.

cache_dir

Location where all cache objects are being stored, defaults to .cache/.

The cache does no longer maintain used/unused intermediates and cache objects due performance reasons (and an edge case described in #67).

classmethod clear(directory=None)

Wipe current cache objects and reset all stored informations.

Parameters:directory – directory to clean (defaults to .cache/
classmethod get(path, key, default=None)

Restore value from obj[key] if mtime has not changed or return default.

Parameters:
  • path – path of this cache object
  • key – key of this value
  • default – default return value
classmethod getmtime(path, default=0.0)

Get last modification timestamp from cache object but store it over the whole compilation process so we have the same value for different views.

Parameters:
  • path – valid cache object
  • default – default value if an OSError occurs
classmethod init(cache_dir=None)

Initialize cache object by creating the cache_dir if non-existent, read all available cache objects and restore memoized key/values.

Parameters:
  • cache_dir – the directory where cache files are stored.
  • mode – the file mode wanted for the cache files, default 0600
classmethod remove(path)

Remove a cache object completely from disk and objects.

classmethod set(path, key, value)

Save a key, value pair into a blob using pickle and moderate zlib compression (level 6). We simply save a dictionary containing all different intermediates (from every view) of an entry.

Parameters:
  • path – path of this cache object
  • key – dictionary key where we store the value
  • value – a string we compress with zlib and afterwards save
classmethod shutdown()

Write memoized key-value pairs to disk.

class acrylamid.core.Environment

Use only for the environment container. This class hides un-hashable keys from Struct hash function.

modified

Return whether the Environment has changed between two runs. This attribute must only be accessed after all modifications to the environment!

class acrylamid.core.Configuration

Similar to Environment but allows hashing of a literarily defined dictionary (that’s the conf.py).

Related Topics

This Page