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
orNone
- 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
orNone
- 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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(warehouse_id, warehouse_elt)[source]
Convert a warehouse XML element into a dictionary.
- 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
orpyramid.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:
request (pyramid.request.Request) – Current request.
index (int) – Index of the tab.
form (.lib.form.Form) – Current form object.
user_filter (chrysalio.lib.filter.Filter) – Filter for users.
user_paging (chrysalio.lib.paging.Paging) – Paging for warehouse users.
- 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:
- 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:
request (pyramid.request.Request) – Current request.
tab_index (int) – Index of the tab.
form (chrysalio.lib.form.Form) – Current form object.
user_filter (chrysalio.lib.filter.Filter) – Filter for users.
user_paging (chrysalio.lib.paging.Paging) – Paging for all users.
jobs (dict) – A dictionary such as
{job_id: (label, description),...}
.groups (dict) – A dictionary such as
{group_id: (label, description),...}
.dbwarehouse (DBWarehouse) – (optional) Current user warehouse SqlAlchemy object.
- 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).
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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(metafield_id, metafield_elt)[source]
Convert a metafield XML element into a dictionary.
- 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
orpyramid.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
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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(indexfield_id, indexfield_elt)[source]
Convert a indexfield XML element into a dictionary.
- 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
orpyramid.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
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
orNone
- Returns:
Error message or
None
.
- 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
orpyramid.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
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.
- 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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(sharing_id, sharing_elt)[source]
Convert a sharing XML element into a dictionary.
- 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
orpyramid.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:
request (pyramid.request.Request) – Current request.
sharing_id (str) – ID of the sharing to delete.
paging (chrysalio.lib.paging.Paging) – (optional) Paging containing displayed files.
- classmethod purge_expired(request, dbsession)[source]
Purge expired sharings.
- Parameters:
request (pyramid.request.Request) – Current request.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(stream_id, stream_elt)[source]
Convert a stream XML element into a dictionary.
- 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
orpyramid.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
- 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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(rule_id, rule_elt)[source]
Convert an user rule XML element into a dictionary.
- 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
orpyramid.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
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 typeonly
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:
- 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:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
root_elt (lxml.etree.Element) – XML element with the namespace of the module.