Model Reference

The models Module

CioWarehouse2 models.

The models.dbfield Module

SQLAlchemy-powered model definitions for fields.

class ciowarehouse2.models.dbfield.DBField(**kwargs)[source]

SQLAlchemy-powered field class.

classmethod xml2db(dbsession: Session, field_elt: Element, error_if_exists: bool = True, kwargs: dict | None = None) str | None[source]

Load a metadata field from a XML element.

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

  • field_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(field_id: str, field_elt: Element)[source]

Convert a field XML element into a dictionary.

Parameters:
  • field_id (str) – Field ID.

  • field_elt (lxml.etree.Element) – Field XML element.

Return type:

dict

classmethod record_format(record: dict)[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: Session | None = None) Element[source]

Serialize a metadata field to a XML representation.

Parameters:

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

Return type:

lxml.etree.Element

class ciowarehouse2.models.dbfield.DBFieldChoice(**kwargs)[source]

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

label(request: Request)[source]

Return a translated label.

Parameters:

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

Return type:

str

The models.dbseed Module

SQLAlchemy-powered model definitions for seeds.

class ciowarehouse2.models.dbseed.DBSeed(**kwargs)[source]

SQLAlchemy-powered seed class.

classmethod xml2db(dbsession: Session, seed_elt: Element, error_if_exists: bool = True, kwargs=None) str | None[source]

Load a seed from a XML element.

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

  • seed_elt (lxml.etree.Element) – Seed XML element.

  • error_if_exists (bool) – (default=True) It returns an error if seed 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(seed_id: str, seed_elt: Element)[source]

Convert an user seed XML element into a dictionary.

Parameters:
  • seed_id (str) – User seed ID.

  • seed_elt (lxml.etree.Element) – Seed XML element.

Return type:

dict

classmethod record_format(record: dict) str | None[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: Session | None = None) Element[source]

Serialize a seed to a XML representation.

Parameters:

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

Return type:

lxml.etree.Element

attachments2directory(attachments: str, directory: str)[source]

Copy from attachments directory the file corresponding to the seed.

See: meth:chrysalio.models.dbase.DBBaseClass.attachments2directory

tab4view(request: Request, tab_index: int, form: Form) str[source]

Generate the tab content of a seed.

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

  • index (int) – Index of the tab.

  • form (.lib.form.Form) – Current form object.

Return type:

chrysalio.helpers.literal.Literal

classmethod settings_schema(request: Request, defaults: dict, dbseed: DBSeed | None = None) tuple[SchemaNode, dict][source]

Return a Colander schema to edit a seed.

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

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

  • dbseed (DBSeed) – (optional) Current scheduled seed SqlAlchemy object.

Return type:

tuple

Returns:

A tuple such as (schema, defaults).

classmethod tab4edit(request: Request, tab_index: int, form: Form, dbseed: DBSeed | None = None) str[source]

Generate the tab content of user seed for edition.

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

  • tab_index (int) – Index of the tab.

  • form (.lib.form.Form) – Current form object.

  • dbseed (DBSeed) – (optional) Current user seed SqlAlchemy object.

Return type:

chrysalio.helpers.literal.Literal

class ciowarehouse2.models.dbseed.DBSeedValue(**kwargs)[source]

Class to link seeds with their values (one-to-many).

The models.dbwarehouse Module

SQLAlchemy-powered model definitions for warehouses.

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

SQLAlchemy-powered warehouse class.

classmethod xml2db(dbsession: Session, warehouse_elt: Element, error_if_exists: bool = True, kwargs: dict | None = None) str | 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: Session, warehouse_elt: Element, kwargs: dict | None)[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'.

xml2db_extra_users_and_groups(dbsession: Session, warehouse_elt: Element, kwargs: dict | None)[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'.

classmethod record_from_xml(warehouse_id: str, warehouse_elt: Element) dict[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: dict) str | None[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: Session) Element[source]

Serialize a warehouse to a XML representation.

Parameters:

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

Return type:

lxml.etree.Element

tab4view(request: Request, tab_index: int, form: Form, user_filter: Filter, user_paging: Paging) str[source]

Generate the tab content of a warehouse.

Parameters:
Return type:

chrysalio.helpers.literal.Literal

classmethod settings_schema(request: Request, defaults: dict, groups: dict, jobs: dict, dbwarehouse: DBWarehouse | None = None) tuple[SchemaNode, dict][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: Request, tab_index: int, form: Form, user_filter: Filter, user_paging: Paging, groups: dict, jobs: dict, dbwarehouse: DBWarehouse | None = None) str[source]

Generate the tab content of user warehouse for edition.

Parameters:
Return type:

chrysalio.helpers.literal.Literal

class ciowarehouse2.models.dbwarehouse.DBWarehouseCardField(**kwargs)[source]

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

class ciowarehouse2.models.dbwarehouse.DBWarehouseListField(**kwargs)[source]

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

class ciowarehouse2.models.dbwarehouse.DBWarehouseMetaField(**kwargs)[source]

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

class ciowarehouse2.models.dbwarehouse.DBWarehouseSeed(**kwargs)[source]

Class to link warehouses with their seeds.

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

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

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

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

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

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

The models.dbsharing Module

SQLAlchemy-powered model definitions for shared files.

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

SQLAlchemy-powered sharing class.

set_password(password: str | None)[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: str) bool[source]

Check the validy of the given password.

Parameters:

password (str) – Clear password to check.

Return type:

bool

classmethod xml2db(dbsession: Session, sharing_elt: Element, error_if_exists: bool = True, kwargs=None) str | 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: str, sharing_elt: Element)[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: dict) str | None[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: Session | None = 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: Request, sharing_id: str) bool[source]

Delete a sharing.

Parameters:
Return type:

bool

classmethod purge_expired(request: Request, dbsession: Session)[source]

Purge expired sharings.

Parameters:
class ciowarehouse2.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 ciowarehouse2.models.dbinput.DBInputStream(**kwargs)[source]

SQLAlchemy-powered stream class.

classmethod xml2db(dbsession: Session, stream_elt: Element, error_if_exists: bool = True, kwargs=None) str | 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: str, stream_elt: Element) dict[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: dict) str | None[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: Session | None = None) Element[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 ciowarehouse2.models.dbinput.DBInputRule(**kwargs)[source]

SQLAlchemy-powered input rule class.

classmethod xml2db(dbsession: Session, rule_elt: Element, error_if_exists: bool = True, kwargs=None) str | 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: str, rule_elt: Element) dict[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: dict) str | None[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: Session | None = None) Element[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 ciowarehouse2.models.dbinput.DBInputRuleVariable(**kwargs)[source]

SQLAlchemy-powered input rule variable class.

class ciowarehouse2.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.

ciowarehouse2.models.populate.xml2db(dbsession: Session, root_elt: Element, only: str | None = None, error_if_exists: bool = True, modules: OrderedDict | None = None) list[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.

ciowarehouse2.models.populate.db2xml(dbsession: Session, root_elt: Element)[source]

Fill root_elt with the XML configuration of the module.

Parameters: