zengine.lib package

zengine.lib.cache module

Base Cache object and some builtin subclasses of it.

class zengine.lib.cache.Cache(*args, **kwargs)[source]

Bases: object

Base cache object to implement specific cache object for each use case.

Subclasses of this class can be consist of just a `PREFIX` attribute;

class MyFooCache(Cache):
    PREFIX = 'FOO'

# create cache object
mycache = MyFooCache(*args)

# set value
mycache.set(value)

# clear the whole PREFIX namespace
MyFooCache.flush()
# initial part(s) of keys can be used for finer control over keys.
MyFooCache.flush('EXTRA_PREFIX')

Or you can override the __init__ method to define strict positional args with docstrings.

class MyFooCache(Cache):
    PREFIX = 'FOO'

    def __init__(self, model_name, obj_key):
        super(MyFooCache, self).__init__(model_name, obj_key)
PREFIX = 'DFT'
SERIALIZE = True
add(val)[source]

Add given value to item (list)

Parameters:val – A JSON serializable object.
Returns:Cache backend response.
decr(delta=1)[source]

Reduce the value of item.

Parameters:delta – Reduction amount.
Returns:Cache backend response.
delete()[source]

Deletes the object.

Returns:Cache backend response.
classmethod flush(*args)[source]

Removes all keys of this namespace Without args, clears all keys starting with cls.PREFIX if called with args, clears keys starting with given cls.PREFIX + args

Parameters:*args – Arbitrary number of arguments.
Returns:List of removed keys.
get(default=None)[source]

return the cached value or default if it can’t be found

Parameters:default – default value
Returns:cached value
get_all()[source]

Get all list items.

Returns:Cache backend response.
get_data_to_cache()[source]
get_or_set(lifetime=None)[source]
incr(delta=1)[source]

Increment the value of item.

Parameters:delta – Incrementation amount.
Returns:Cache backend response.
remove_all()[source]

Remove items of the list.

Returns:Cache backend response.
remove_item(val)[source]

Removes given item from the list.

Parameters:val – Item
Returns:Cache backend response.
set(val, lifetime=None)[source]

set cache value

Parameters:
  • val – any picklable object
  • lifetime – exprition time in sec
Returns:

val

class zengine.lib.cache.CatalogCache(lang_code, key)[source]

Bases: zengine.lib.cache.Cache

Cache object for the CatalogData.

Parameters:
  • lang_code – Language code
  • key – Item key
PREFIX = 'CTDT'
class zengine.lib.cache.ClearCache(*args, **kwargs)[source]

Bases: zengine.lib.cache.Cache

Empty cache object to flush all cache entries

PREFIX = ''
class zengine.lib.cache.KeepAlive(user_id=None, sess_id=None)[source]

Bases: zengine.lib.cache.Cache

Websocket keepalive request timestamp store

Parameters:
  • user_id – User key
  • sess_id – Session id
PREFIX = 'KEEP'
SERIALIZE = False
SESSION_EXPIRE_TIME = 300
is_alive()[source]
reset()[source]
update_or_expire_session()[source]

Deletes session if keepalive request expired otherwise updates the keepalive timestamp value

class zengine.lib.cache.Session(sessid='')[source]

Bases: object

Redis based dict like session object to store user session data

Examples

sess = Session(session_key)
sess['user_data'] = {"foo":"bar"}
sess
Parameters:sessid – user session id.
PREFIX = 'SES'
delete()[source]
Removes all contents attached to this session object.
If sessid is empty, all sessions will be cleaned up.
get(key, default=None)[source]
items()[source]
keys()[source]
values()[source]
class zengine.lib.cache.UserSessionID(user_id)[source]

Bases: zengine.lib.cache.Cache

Cache object for the User -> Active Session ID.

Parameters:user_id – User key
PREFIX = 'USID'
SERIALIZE = False
class zengine.lib.cache.WFSpecNames[source]

Bases: zengine.lib.cache.Cache

PREFIX = 'WFSPECNAMES'
static get_data()[source]
get_data_to_cache()[source]
refresh()[source]

zengine.lib.camunda_bpmn_packager module

zengine.lib.camunda_parser module

zengine.lib.catalog_data module

Catalog Data module.

class zengine.lib.catalog_data.CatalogData[source]

Bases: object

Manager object for the user updatable multi language texts

CACHE = defaultdict(<type 'dict'>, {})
CURRENT_LANG_CODE = None
ITEM_CACHE = defaultdict(<type 'dict'>, {})
get_all(cat)[source]
if data can’t found in cache then it will be fetched from db,
parsed and stored to cache for each lang_code.
Parameters:cat – cat of catalog data
Returns:
get_all_as_dict(cat)[source]

Transforms get_all method’s results to key value pairs in dict.

Parameters:cat (str) – catalog data key name

Returns(dict): key-value pair dict.

zengine.lib.exceptions module

exception zengine.lib.exceptions.ConfigurationError[source]

Bases: zengine.lib.exceptions.ZengineError

pass

exception zengine.lib.exceptions.FormValidationError[source]

Bases: zengine.lib.exceptions.ZengineError

pass

exception zengine.lib.exceptions.HTTPError(code, message=None)[source]

Bases: zengine.lib.exceptions.ZengineError

Exception thrown for an unsuccessful HTTP request.

Attributes:

  • code - HTTP error integer error code, e.g. 404. Error code 599 is used when no HTTP response was received, e.g. for a timeout.
exception zengine.lib.exceptions.PermissionDenied[source]

Bases: zengine.lib.exceptions.ZengineError

The user did not have permission to do that

exception zengine.lib.exceptions.SecurityInfringementAttempt[source]

Bases: zengine.lib.exceptions.ZengineError

Someone tried to do something nasty

exception zengine.lib.exceptions.SuspiciousOperation[source]

Bases: zengine.lib.exceptions.ZengineError

The user did something suspicious

exception zengine.lib.exceptions.ViewDoesNotExist[source]

Bases: zengine.lib.exceptions.ZengineError

The requested view does not exist

exception zengine.lib.exceptions.ZengineError[source]

Bases: exceptions.Exception

pass

zengine.lib.test_utils module

zengine.lib.utils module