Model Reference

The models Module

CioDashboard models.

The models.dbdashboard Module

SQLAlchemy-powered model definitions for dashboards.

class ciodashboard.models.dbdashboard.DBDashboard(**kwargs)[source]

SQLAlchemy-powered dashboard class.

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

Load a dashboard from a XML element.

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

  • dashboard_elt (lxml.etree.Element) – Dashboard XML element.

  • error_if_exists (bool) – (default=True) It returns an error if user dashboard 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(dashboard_id, dashboard_elt)[source]

Convert a dashboard XML element into a dictionary.

Parameters:
  • dashboard_id (str) – Dashboard ID.

  • dashboard_elt (lxml.etree.Element) – Dashboard 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 dashboard 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 dashboard.

Parameters:
Return type:

chrysalio.helpers.literal.Literal

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

Return a Colander schema to edit a dashboard.

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),...}.

  • dbdashboard (DBDashboard) – (optional) Current user dashboard SqlAlchemy object.

Return type:

tuple

Returns:

A tuple such as (schema, defaults).

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

Generate the tab content of user dashboard for edition.

Parameters:
Return type:

chrysalio.helpers.literal.Literal

class ciodashboard.models.dbdashboard.DBDashboardGauge(**kwargs)[source]

Class to link dashboards with their authorized gauges (many-to-many).

class ciodashboard.models.dbdashboard.DBDashboardUser(**kwargs)[source]

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

class ciodashboard.models.dbdashboard.DBDashboardGroup(**kwargs)[source]

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

The models.populate Module

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

ciodashboard.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.

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

Fill root_elt with the XML configuration of the module.

Parameters: