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 or dict) – 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:
Return type:

tuple

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 or None

check_activations(modules_off)[source]

Check activations.

Parameters:

modules_off (set) – Set of inactive modules.

Return type:

bool

Returns:

True if an activation occurs.

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 type only are loaded.

  • error_if_exists (bool) – It returns an error if an item already exists.

Return type:

list

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:

list

Returns:

A list of XML elements.

populate(args, registry, dbsession)[source]

Method called by populate script to complete the operation.

Parameters:
Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

backup(args, registry, dbsession, directory)[source]

Method called by backup script to complete the operation.

Parameters:
Return type:

pyramid.i18n.TranslationString or None

Returns:

Error message or None.

activate(registry, dbsession)[source]

Method to activate the module.

Parameters:
deactivate(registry, dbsession)[source]

Method to deactivate the module.

Parameters:
classmethod check_activated(request, module_id)[source]

Check if the module is active and raise an HTTPForbidden exception if not.

Parameters:
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:
deactivate(registry, dbsession)[source]

Method to deactivate the module.

Parameters:
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:

tuple

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 or None

Returns:

Error message or None.

reset_configuration()[source]

Reset the configuration.

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:
Return type:

pyramid.i18n.TranslationString or None

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:

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()[source]

Serialize LDAP settings to a XML representation.

Return type:

lxml.etree.Element

classmethod attachments2directory(attachments, directory)[source]

Copy from attachments directory the file corresponding to the ldap.

Parameters:
  • attachments (str) – Absolute path to the attachements directory.

  • directory (str) – The backup directory.

sheet4view(request, form, profile_labels)[source]

Generate the sheet content.

Parameters:
Parem dict profile_labels:

Label in user language of all profile.

Return type:

helpers.literal.Literal

classmethod settings_schema(profiles, dbldap=None)[source]

Return a Colander schema to edit LDAP.

Parameters:
  • profiles (dict) – A dictionary such as {profile_id: label,...}.

  • dbldap (DBLdap) – (optional) Current CIOLdap SqlAlchemy object.

Return type:

tuple

Returns:

A tuple such as (schema, defaults).

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

chrysalio.modules.cioldap.models.populate.db2xml(dbsession, root_elt)[source]

Return a list of XML elements.

Parameters:

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:
deactivate(registry, dbsession)[source]

Method to deactivate the module.

Parameters:

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 or None

Returns:

Error message or None.

classmethod record_from_xml(bone_id, bone_elt)[source]

Convert a bone XML element into a dictionary.

Parameters:
  • bone_id (str) – Bone ID.

  • bone_elt (lxml.etree.Element) – Bone 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()[source]

Serialize a bone to a XML representation.

Return type:

lxml.etree.Element

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

chrysalio.modules.cioskeleton.models.populate.db2xml(dbsession, root_elt)[source]

Return a list of XML elements.

Parameters:

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.

index()[source]

List all bones.