Model Reference
The models
Module
CioService models.
The models.dbjob
Module
SQLAlchemy-powered model definitions for jobs.
- class cioservice.models.dbjob.DBJob(**kwargs)[source]
SQLAlchemy-powered job class.
- classmethod xml2db(dbsession, job_elt, error_if_exists=True, kwargs=None)[source]
Load a job from a XML element.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
job_elt (lxml.etree.Element) – Job XML element.
error_if_exists (bool) – (default=True) It returns an error if job already exists.
kwargs (dict) – (optional) Dictionary of keyword arguments.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(job_id, job_elt)[source]
Convert an user job 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 job to a XML representation.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- Return type:
lxml.etree.Element
- db2xml_extra(dbsession, job_elt)[source]
Serialize depedencies of a job to a XML representation.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
job_elt (lxml.etree.Element) – Job XML element.
- attachments2directory(attachments, directory)[source]
Copy from attachments directory the file corresponding to the job.
See: meth:.models.DBBaseClass.attachments2directory
- tab4view(request, tab_index, form, user_filter, user_paging)[source]
Generate the tab content of a job.
- Parameters:
request (pyramid.request.Request) – Current request.
index (int) – Index of the tab.
form (.lib.form.Form) – Current form object.
user_filter (.lib.filter.Filter) – Filter for users.
user_paging (.lib.paging.Paging) – Paging for job users.
- Return type:
chrysalio.helpers.literal.Literal
- classmethod settings_schema(request, defaults, groups, dbjob=None, relax=False)[source]
Return a Colander schema to edit a job.
- 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),...}
.dbjob (DBJob) – (optional) Current scheduled job SqlAlchemy object.
relax (bool) – (default=False) If
True
,required
is ignored.
- Return type:
- Returns:
A tuple such as
(schema, defaults)
.
- classmethod tab4edit(request, tab_index, form, user_filter, user_paging, groups, dbjob=None)[source]
Generate the tab content of user job for edition.
- Parameters:
request (pyramid.request.Request) – Current request.
tab_index (int) – Index of the tab.
form (.lib.form.Form) – Current form object.
user_filter (.lib.filter.Filter) – Filter for users.
user_paging (.lib.paging.Paging) – Paging for all users.
groups (dict) – A dictionary such as
{group_id: (label, description),...}
.dbjob (DBJob) – (optional) Current user job SqlAlchemy object.
- Return type:
chrysalio.helpers.literal.Literal
- class cioservice.models.dbjob.DBJobArea(**kwargs)[source]
Class to link jobs with their areas (one-to-many).
- class cioservice.models.dbjob.DBJobValue(**kwargs)[source]
Class to link jobs with their values (one-to-many).
- class cioservice.models.dbjob.DBJobUser(**kwargs)[source]
Class to link jobs with their authorized users (many-to-many).
The models.populate
Module
Function to import and export database from and into XML files.
- cioservice.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.
- cioservice.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.