Model Reference

The models Module

CioWarehouse models.

The models.dbwarehouse Module

SQLAlchemy-powered model definitions for warehouses.

class ciowarehouse.models.dbwarehouse.DBWarehouse(**kwargs)[source]

SQLAlchemy-powered warehouse class.

classmethod xml2db(dbsession, warehouse_elt, error_if_exists=True, kwargs=None)[source]

Load a warehouse from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • warehouse_elt (lxml.etree.Element) – Warehouse XML element.

  • error_if_exists (bool) – (default=True) It returns an error if user warehouse already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

xml2db_extra(dbsession, warehouse_elt, kwargs)[source]

Load extra information on a warehouse from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • warehouse_elt (lxml.etree.Element) – User XML element.

  • kwargs (dict) – Dictionary of keyword arguments with the key 'profiles'.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

xml2db_extra_users_and_groups(dbsession, warehouse_elt, kwargs)[source]

Load users and groups from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • warehouse_elt (lxml.etree.Element) – User XML element.

  • kwargs (dict) – Dictionary of keyword arguments with the key 'profiles'.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(warehouse_id, warehouse_elt)[source]

Convert a warehouse XML element into a dictionary.

Parameters:
  • warehouse_id (str) – Warehouse ID.

  • warehouse_elt (lxml.etree.Element) – Warehouse XML element.

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession)[source]

Serialize a warehouse to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

Return type:

lxml.etree.Element

tab4view(request, tab_index, form, user_filter, user_paging)[source]

Generate the tab content of a warehouse.

Parameters:
Return type:

chrysalio.helpers.literal.Literal

classmethod settings_schema(request, defaults, groups, jobs, dbwarehouse=None)[source]

Return a Colander schema to edit a warehouse.

Parameters:
  • request (pyramid.request.Request) – Current request.

  • defaults (dict) – Default values for the form set by the user paging object.

  • groups (dict) – A dictionary such as {group_id: (label, description),...}.

  • jobs (dict) – A dictionary such as {job_id: (label, description),...}.

  • dbwarehouse (DBWarehouse) – (optional) Current user warehouse SqlAlchemy object.

Return type:

tuple

Returns:

A tuple such as (schema, defaults).

classmethod tab4edit(request, tab_index, form, user_filter, user_paging, groups, jobs, dbwarehouse=None)[source]

Generate the tab content of user warehouse for edition.

Parameters:
Return type:

chrysalio.helpers.literal.Literal

class ciowarehouse.models.dbwarehouse.DBWarehouseMetafield(**kwargs)[source]

Class to link warehouses with their metadata fields (many-to-many).

class ciowarehouse.models.dbwarehouse.DBWarehouseIndexfield(**kwargs)[source]

Class to link warehouses with their list index fields (many-to-many).

class ciowarehouse.models.dbwarehouse.DBWarehouseHandler(**kwargs)[source]

Class to link warehouses with their handler.

class ciowarehouse.models.dbwarehouse.DBWarehouseJob(**kwargs)[source]

Class to link warehouses with their jobs (one-to-many).

class ciowarehouse.models.dbwarehouse.DBWarehouseUser(**kwargs)[source]

Class to link warehouses with their authorized users (many-to-many).

class ciowarehouse.models.dbwarehouse.DBWarehouseGroup(**kwargs)[source]

Class to link warehouses with their authorized groups (many-to-many).

The models.dbmetafield Module

SQLAlchemy-powered model definitions for metadata fields.

class ciowarehouse.models.dbmetafield.DBMetafield(**kwargs)[source]

SQLAlchemy-powered metadata field class.

classmethod xml2db(dbsession, metafield_elt, error_if_exists=True, kwargs=None)[source]

Load a metadata field from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • metafield_elt (lxml.etree.Element) – Metadata field XML element.

  • error_if_exists (bool) – (default=True) It returns an error if metadata field already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(metafield_id, metafield_elt)[source]

Convert a metafield XML element into a dictionary.

Parameters:
  • metafield_id (str) – Metafield ID.

  • metafield_elt (lxml.etree.Element) – Metafield XML element.

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession=None)[source]

Serialize a metadata field to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – (optional) SQLAlchemy session.

Return type:

lxml.etree.Element

class ciowarehouse.models.dbmetafield.DBMetafieldChoice(**kwargs)[source]

SQLAlchemy-powered metadata field choices class (one-to-many).

label(request)[source]

Return a translated label.

Parameters:

request (pyramid.request.Request) – Current request.

Return type:

str

The models.dbindexfield Module

SQLAlchemy-powered model definitions for index fields.

class ciowarehouse.models.dbindexfield.DBIndexfield(**kwargs)[source]

SQLAlchemy-powered index field class.

classmethod xml2db(dbsession, indexfield_elt, error_if_exists=True, kwargs=None)[source]

Load a index field from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • indexfield_elt (lxml.etree.Element) – Index field XML element.

  • error_if_exists (bool) – (default=True) It returns an error if index field already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(indexfield_id, indexfield_elt)[source]

Convert a indexfield XML element into a dictionary.

Parameters:
  • indexfield_id (str) – Indexfield ID.

  • indexfield_elt (lxml.etree.Element) – Indexfield XML element.

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession=None)[source]

Serialize a index field to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – (optional) SQLAlchemy session.

Return type:

lxml.etree.Element

class ciowarehouse.models.dbindexfield.DBIndexfieldChoice(**kwargs)[source]

SQLAlchemy-powered index field choices class (one-to-many).

label(request)[source]

Return a translated label.

Parameters:

request (pyramid.request.Request) – Current request.

Return type:

str

The models.dbhandler Module

SQLAlchemy-powered model definitions for file handlers.

class ciowarehouse.models.dbhandler.DBHandler(**kwargs)[source]

SQLAlchemy-powered file handler class.

classmethod xml2db(dbsession, handler_elt, error_if_exists=True, kwargs=None)[source]

Load a file handler from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • handler_elt (lxml.etree.Element) – File handler XML element.

  • error_if_exists (bool) – (default=True) It returns an error if file handler already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(handler_id)[source]

Convert a handler XML element into a dictionary.

Parameters:

handler_id (str) – Handler ID.

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession=None)[source]

Serialize a file handler to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – (optional) SQLAlchemy session.

Return type:

lxml.etree.Element

class ciowarehouse.models.dbhandler.DBHandlerIndexer(**kwargs)[source]

Class to link handlers with their indexers (one-to-many).

The models.dbsharing Module

SQLAlchemy-powered model definitions for shared files.

class ciowarehouse.models.dbsharing.DBSharing(**kwargs)[source]

SQLAlchemy-powered sharing class.

set_password(password)[source]

Set the password, possibly hashing it.

Parameters:

password (str) – Password to set. If it does not begin with $, we use bcrypt algorithm before setting.

check_password(password)[source]

Check the validy of the given password.

Parameters:

password (str) – Clear password to check.

Return type:

bool

classmethod xml2db(dbsession, sharing_elt, error_if_exists=True, kwargs=None)[source]

Load a shared file from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • sharing_elt (lxml.etree.Element) – Sharing XML element.

  • error_if_exists (bool) – (default=True) It returns an error if sharing already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(sharing_id, sharing_elt)[source]

Convert a sharing XML element into a dictionary.

Parameters:
  • sharing_id (str) – Sharing ID.

  • sharing_elt (lxml.etree.Element) – Sharing XML element.

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession=None)[source]

Serialize a sharing to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – (optional) SQLAlchemy session.

Return type:

lxml.etree.Element

classmethod delete(request, sharing_id, paging=None)[source]

Delete a sharing.

Parameters:
classmethod purge_expired(request, dbsession)[source]

Purge expired sharings.

Parameters:
class ciowarehouse.models.dbsharing.DBSharingFile(**kwargs)[source]

Class to link sharing token with their files (one-to-many).

The models.dbinput Module

SQLAlchemy-powered model definitions for input streams (file, FTP or email) and input rules.

class ciowarehouse.models.dbinput.DBInputStream(**kwargs)[source]

SQLAlchemy-powered stream class.

classmethod xml2db(dbsession, stream_elt, error_if_exists=True, kwargs=None)[source]

Load an stream description from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • stream_elt (lxml.etree.Element) – Stream XML element.

  • error_if_exists (bool) – (default=True) It returns an error if stream already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(stream_id, stream_elt)[source]

Convert a stream XML element into a dictionary.

Parameters:

stream_id (str) – Stream ID (identifier or mail address).

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession=None)[source]

Serialize a file stream to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – (optional) SQLAlchemy session.

Return type:

lxml.etree.Element

attachments2directory(attachments, directory)[source]

Copy from attachments directory the file corresponding to the user.

Parameters:
  • attachments (str) – Absolute path to the attachments directory.

  • directory (str) – The backup directory.

class ciowarehouse.models.dbinput.DBInputRule(**kwargs)[source]

SQLAlchemy-powered input rule class.

classmethod xml2db(dbsession, rule_elt, error_if_exists=True, kwargs=None)[source]

Load a user rule from a XML element.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • rule_elt (lxml.etree.Element) – User rule XML element.

  • error_if_exists (bool) – (default=True) It returns an error if user rule already exists.

  • kwargs (dict) – (optional) Dictionary of keyword arguments.

Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

classmethod record_from_xml(rule_id, rule_elt)[source]

Convert an user rule XML element into a dictionary.

Parameters:
  • rule_id (str) – Rule ID.

  • rule_elt (lxml.etree.Element) – Rule XML element.

Return type:

dict

classmethod record_format(record)[source]

Check and possibly correct a record before inserting it in the database.

Parameters:

record (dict) – Dictionary of values to check.

Return type:

None or pyramid.i18n.TranslationString

Returns:

None or error message.

db2xml(dbsession=None)[source]

Serialize an user rule to a XML representation.

Parameters:

dbsession (sqlalchemy.orm.session.Session) – (optional) SQLAlchemy session.

Return type:

lxml.etree.Element

attachments2directory(attachments, directory)[source]

Copy from attachments directory the file corresponding to the user.

Parameters:
  • attachments (str) – Absolute path to the attachments directory.

  • directory (str) – The backup directory.

class ciowarehouse.models.dbinput.DBInputRuleVariable(**kwargs)[source]

SQLAlchemy-powered input rule variable class.

class ciowarehouse.models.dbinput.DBInputRuleCondition(**kwargs)[source]

SQLAlchemy-powered input rule condition class.

The models.populate Module

Function to import and export database from and into XML files.

ciowarehouse.models.populate.xml2db(dbsession, root_elt, only=None, error_if_exists=True, modules=None)[source]

Load an XML configuration file for an included module.

Parameters:
  • dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.

  • root_elt (lxml.etree.Element) – XML element with the namespace of the module.

  • only (str) – (optional) If not None, only the items of type only are loaded.

  • error_if_exists (bool) – (default=True) It returns an error if an item already exists.

  • modules (collections.OrderedDict) – (optional) Dictionary of modules to use to complete the loading.

Return type:

list

Returns:

A list of error messages.

ciowarehouse.models.populate.db2xml(dbsession, root_elt)[source]

Fill root_elt with the XML configuration of the module.

Parameters: