Modules Reference
The modules
Module
Base class for modules.
- class chrysalio.modules.Module(config_ini)[source]
Base class for included modules.
- Parameters:
config_ini (str) – Absolute path to the configuration file (e.g. development.ini).
- classmethod register(environment, module_class)[source]
Method to register the module.
- Parameters:
environment (
pyramid.config.Configurator
ordict
) – Object used to do configuration declaration within the application or a ScriptRegistry to simulate the application registry.module_class – Module class.
- classmethod check_conflicts(includes, modules)[source]
Check conflicts between modules. Return a list of IDs of avaliable modules and IDs of implemented functionalities.
- Parameters:
includes (list) – List of available includes.
modules (collections.OrderedDict) – Dictionary of available modules.
- Return type:
- Returns:
A tuple such as
(implementation_list, error)
.
- check_dependencies(implementations)[source]
Check dependencies.
- Parameters:
implementations (list) – List containing the IDs of available includes plus the IDS of functionalities implemented by each available module.
- Return type:
pyramid.i18n.TranslationString
orNone
- module_xml2db(dbsession, tree, only, error_if_exists)[source]
Load an XML configuration file for the module.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
tree (lxml.etree.ElementTree) – Content of the XML document.
only (str) – If not
None
, only the items of typeonly
are loaded.error_if_exists (bool) – It returns an error if an item already exists.
- Return type:
- Returns:
A list of error messages.
- module_db2xml(dbsession)[source]
Return a list of XML elements of the module.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- Return type:
- Returns:
A list of XML elements.
- populate(args, registry, dbsession)[source]
Method called by populate script to complete the operation.
- Parameters:
args (argparse.Namespace) – Command line arguments.
registry (dict) – Dictionary registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
.
- backup(args, registry, dbsession, directory)[source]
Method called by backup script to complete the operation.
- Parameters:
args (argparse.Namespace) – Command line arguments.
registry (dict) – Dictionary registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
directory (str) – Path to the backup directory.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
.
- activate(registry, dbsession)[source]
Method to activate the module.
- Parameters:
registry (pyramid.registry.Registry) – Application registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- deactivate(registry, dbsession)[source]
Method to deactivate the module.
- Parameters:
registry (pyramid.registry.Registry) – Application registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- classmethod check_activated(request, module_id)[source]
Check if the module is active and raise an HTTPForbidden exception if not.
- Parameters:
request (pyramid.request.Request) – Current request.
module_id (str) – ID of checked module.
- configuration_route(request)[source]
Return the route to configure this module.
- Parameters:
request (pyramid.request.Request) – Current request.
The modules.cioldap
Module
CioLDAP, a module to manage LDAP authentication.
- chrysalio.modules.cioldap.includeme(configurator)[source]
Function to register the module.
- Parameters:
configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.
- class chrysalio.modules.cioldap.ModuleCioLDAP(config_ini)[source]
Class for CioLDAP module.
- Parameters:
config_ini (str) – Absolute path to the configuration file (e.g. development.ini).
- activate(registry, dbsession)[source]
Method to activate the module.
- Parameters:
registry (pyramid.regisry.Registry) – Application registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- deactivate(registry, dbsession)[source]
Method to deactivate the module.
- Parameters:
registry (pyramid.registry.Registry) – Application registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- configuration_route(request)[source]
Return the route to configure this module.
- Parameters:
request (pyramid.request.Request) – Current request.
The modules.cioldap.lib
Module
Class to manage LDAP as an authority for authentication.
- class chrysalio.modules.cioldap.lib.ldap.LDAP[source]
Authority class to manage LDAP authentication.
It reads its parameters in its SQL table. The default values are:
host: localhost
port: 389
ssl: false
check_interval: 0 (no cache)
user_filter: (&(objectclass=inetOrgPerson)(uid=_UID_))
field_firstname: givenName
field_lastname: sn
field_email: mail
- get(request, login, password, dbuser_class)[source]
Get user from LDAP server.
- Parameters:
request (pyramid.request.Request) – Current request.
login (str) – Login of the user to authenticate.
password (str) – Clear password.
dbuser_class (.models.dbuser.DBUser) – The SQL class to create a user.
- Return type:
- Returns:
A tuple like
(dbuser, error)
. It can be(None, None)
- check(request, login, password, dbuser)[source]
Check user authorization according to LDAP server.
- Parameters:
request (pyramid.request.Request) – Current request.
login (str) – Login of the user to authenticate.
password (str) – Clear password.
dbuser (.models.dbuser.DBUser) – The SQL object of the user to check.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
.
The modules.cioldap.models
Module
SQLAlchemy-powered model definitions for LDAP.
- class chrysalio.modules.cioldap.models.dbldap.DBLdap(**kwargs)[source]
SQLAlchemy-powered LDAP class.
- classmethod xml2db(dbsession, ldap_elt)[source]
Load LDAP settings from a XML element.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
ldap_elt (lxml.etree.Element) – Ldap XML element.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(ldap_elt)[source]
Convert a LDAP XML element into a dictionary.
- Parameters:
ldap_elt (lxml.etree.Element) – LDAP XML element.
- Return type:
- 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.
- classmethod attachments2directory(attachments, directory)[source]
Copy from attachments directory the file corresponding to the ldap.
- sheet4view(request, form, profile_labels)[source]
Generate the sheet content.
- Parameters:
request (pyramid.request.Request) – Current request.
form (.lib.form.Form) – Current form object.
- Parem dict profile_labels:
Label in user language of all profile.
- Return type:
helpers.literal.Literal
- classmethod sheet4edit(request, form, profiles)[source]
Generate the tab content for edition.
- Parameters:
request (pyramid.request.Request) – Current request.
form (.lib.form.Form) – Current form object.
profiles (dict) – A dictionary such as
{profile_id: label,...}
.
- Return type:
helpers.literal.Literal
- class chrysalio.modules.cioldap.models.dbldap.DBLdapProfile(**kwargs)[source]
Class to link LDAP with its profiles (one-to-many).
Function to import and export database from and into XML files.
- chrysalio.modules.cioldap.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.
- chrysalio.modules.cioldap.models.populate.db2xml(dbsession, root_elt)[source]
Return a list of XML elements.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
root_elt (lxml.etree._Element) – XML element with the namespace of the module.
The modules.cioskeleton
Module
An example of a module for Chrysalio with dependencies, permissions, routes, views and menu.
- chrysalio.modules.cioskeleton.includeme(configurator)[source]
Function to register the module.
- Parameters:
configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.
- class chrysalio.modules.cioskeleton.ModuleCioSkeleton(config_ini)[source]
Class for an example of Chrysalio module.
- Parameters:
config_ini (str) – Absolute path to the configuration file (e.g. development.ini).
- activate(registry, dbsession)[source]
Method to activate the module.
- Parameters:
registry (pyramid.registry.Registry) – Application registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
- deactivate(registry, dbsession)[source]
Method to deactivate the module.
- Parameters:
registry (pyramid.registry.Registry) – Application registry.
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
The modules.cioskeleton.models
Module
SQLAlchemy-powered model definitions for bones.
- class chrysalio.modules.cioskeleton.models.dbbone.DBBone(**kwargs)[source]
SQLAlchemy-powered bone class.
- label
- classmethod xml2db(dbsession, bone_elt, error_if_exists=True, kwargs=None)[source]
Load a bone from a XML element.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
bone_elt (lxml.etree.Element) – Bone XML element.
error_if_exists (bool) – (default=True) It returns an error if bone already exists.
kwargs (dict) – (optional) Dictionary of keyword arguments.
- Return type:
pyramid.i18n.TranslationString
orNone
- Returns:
Error message or
None
.
- classmethod record_from_xml(bone_id, bone_elt)[source]
Convert a bone XML element into a dictionary.
Function to import and export database from and into XML files.
- chrysalio.modules.cioskeleton.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.
- chrysalio.modules.cioskeleton.models.populate.db2xml(dbsession, root_elt)[source]
Return a list of XML elements.
- Parameters:
dbsession (sqlalchemy.orm.session.Session) – SQLAlchemy session.
root_elt (lxml.etree._Element) – XML element with the namespace of the module.
The modules.cioskeleton.views
Module
Bone view callables.
- class chrysalio.modules.cioskeleton.views.bone.BoneView(request)[source]
Class to show how to add views with a module.
- Parameters:
request (pyramid.request.Request) – Current request.