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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(field_id: str, field_elt: Element)[source]
Convert a field XML element into a dictionary.
- 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
orpyramid.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
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
orNone
- 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.
- 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
orpyramid.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:
- 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
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
orNone
- 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.
- 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
orpyramid.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:
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: 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:
- 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:
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 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).
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.
- 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
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(sharing_id: str, sharing_elt: Element)[source]
Convert a sharing XML element into a dictionary.
- 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
orpyramid.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:
request (pyramid.request.Request) – Current request.
sharing_id (str) – ID of the sharing to delete.
- Return type:
- classmethod purge_expired(request: Request, dbsession: Session)[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 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
orNone
- 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.
- 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
orpyramid.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
- 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
orNone
- 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.
- 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
orpyramid.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
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 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.
- ciowarehouse2.models.populate.db2xml(dbsession: Session, root_elt: Element)[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.