Model Reference

The models Module

Here are defined database main objects and constants.

publiforge.models.close_dbsession(request)[source]

Call back function to close database session.

Parameters:request – (pyramid.request.Request instance) Current request.

The models.users Module

SQLAlchemy-powered model definition for users.

class publiforge.models.users.User(settings, login, status, password, name, email, lang='en', expiration=None, restrict_ip=False, home=None, page_size=None, created=None, updated=None)[source]

SQLAlchemy-powered user model.

classmethod load(settings, user_elt, error_if_exists=True)[source]

Load a user from a XML element.

Parameters:
  • settings – (dictionary) Application settings.
  • user_elt – (lxml.etree.Element instance) User XML element.
  • error_if_exists – (boolean, default=True) It returns an error if user already exists.
Returns:

(pyramid.i18n.TranslationString or None) Error message or None.

set_password(settings, password)[source]

Encrypt and set password.

Parameters:
  • settings – (dictionary) Pyramid deployment settings.
  • password – (string) Clear password.
setup_environment(request)[source]

Set up user environment (session and cookie).

Parameters:request – (pyramid.request.Request instance) Current request.

It saves in session the following values:

  • user_id: user ID
  • login: user login
  • name: user name
  • lang: user language
  • home: home page content
  • paging: paging environment
  • perms: list of permissions
xml(i_manager=False)[source]

Serialize a user to a XML representation.

Parameters:i_manager – (boolean, default=False) Am I a user manager?
Returns:(lxml.etree.Element)
class publiforge.models.users.UserFile(path, user_id=None)[source]

SQLAlchemy-powered user selection model.

class publiforge.models.users.UserIP(user_id, ip)[source]

Class for restriction by IP.

class publiforge.models.users.UserPerm(user_id, scope, level)[source]

SQLAlchemy-powered user permission class.

The models.groups Module

SQLAlchemy-powered model definition for groups.

class publiforge.models.groups.Group(group_id, label, description=None)[source]

SQLAlchemy-powered group model.

classmethod load(group_elt, error_if_exists=True)[source]

Load a group from a XML element.

Parameters:
  • group_elt – (lxml.etree.Element instance) Group XML element.
  • error_if_exists – (boolean, default=True) It returns an error if group already exists.
Returns:

(pyramid.i18n.TranslationString or None) Error message or None.

xml()[source]

Serialize a group to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.groups.GroupPerm(group_id, scope, level)[source]

SQLAlchemy-powered group permission class.

The models.storages Module

SQLAlchemy-powered model definition for storages.

class publiforge.models.storages.Storage(settings, storage_id, label, description=None, vcs_engine='local', vcs_url=None, vcs_user=None, vcs_password=None, public_url=None, access=None, refresh=None, indexed_files=None, normalize_mode=None)[source]

SQLAlchemy-powered storage model.

classmethod delete(storage_root, storage_id)[source]

Delete a storage.

Parameters:
  • storage_root – (string) Storage root path.
  • storage_id – (string) Storage identifier.
classmethod load(settings, storage_elt, error_if_exists=True)[source]

Load a storage from a XML element.

Parameters:
  • settings – (dictionary) Application settings.
  • storage_elt – (lxml.etree.Element instance) Storage XML element.
  • error_if_exists – (boolean, default=True) It returns an error if storage already exists.
Returns:

(pyramid.i18n.TranslationString None or Storage instance) Error message or None or the new storage object.

set_vcs_password(settings, vcs_password)[source]

Encrypt and set password.

Parameters:
  • settings – (dictionary) Pyramid deployment settings.
  • vcs_password – (string) Clear VCS password.
xml()[source]

Serialize a storage to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.storages.StorageGroup(storage_id, group_id, perm=None)[source]

SQLAlchemy-powered association table between Storage and Group.

class publiforge.models.storages.StorageOpener(storage_id, opener_id, sort=0)[source]

SQLAlchemy-powered association table between Storage and its openers.

class publiforge.models.storages.StorageUser(storage_id, user_id, in_menu=False, perm='reader', vcs_user=None, vcs_password=None, settings=None)[source]

SQLAlchemy-powered association table between Storage and User.

set_vcs_password(settings, vcs_password)[source]

Encrypt and set VCS password.

Parameters:
  • settings – (dictionary) Pyramid deployment settings.
  • password – (string) Clear password.

The models.indexers Module

SQLAlchemy-powered model definition for groups.

class publiforge.models.indexers.Indexer(indexer_id, labels, value_type, display=None, result_column=None)[source]

SQLAlchemy-powered indexer model.

label(lang, default_lang='en')[source]

Return the label in language lang.

Parameters:
  • lang – (string) Asked language.
  • default_lang – (string) Default language.
Returns:

(string)

classmethod load(indexer_elt, error_if_exists=True)[source]

Load a indexer from a XML element.

Parameters:
  • indexer_elt – (lxml.etree.Element instance) Indexer XML element.
  • error_if_exists – (boolean, default=True) It returns an error if indexer already exists.
Returns:

(pyramid.i18n.TranslationString or None) Error message or None.

xml()[source]

Serialize a indexer to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.indexers.IndexerExtractor(indexed_files, extractor_type, parameter, limit=None)[source]

SQLAlchemy-powered indexer extractor class.

xml()[source]

Serialize an extractor to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.indexers.IndexerValue(label, value=None)[source]

SQLAlchemy-powered indexer value class.

The models.processors Module

SQLAlchemy-powered model definition for processors.

class publiforge.models.processors.Processor(processor_id)[source]

SQLAlchemy-powered processor model.

classmethod description(request, processor_id=None, xml=None)[source]

Description of processor processor_id in local language or default language.

Parameters:
  • request – (pyramid.request.Request instance) Current request.
  • processor_id – (string, optional) Processor ID.
  • xml – (lxml.etree.ElementTree instance, optional) Processor XML.
Returns:

(string) Description.

If some labels do not exist in the asked language, this method returns the label in default language or processor_id.

classmethod ids(request)[source]

ID of all processors.

Parameters:request – (pyramid.request.Request instance) Current request.
Returns:(list)
classmethod labels(request)[source]

Label of all processors in local language or default language.

Parameters:request – (pyramid.request.Request instance) Current request.
Returns:(dictionary) A dictionary such as {<processor_id>: <processor_label>,...}.

If some labels do not exist in the asked language, this method returns the label in default language or processor_id.

classmethod load(processor_id, xml)[source]

Load a processor from a XML string.

Parameters:
  • processor_id – (string) Processor ID.
  • xml – (string) XML string.
Returns:

(string, pyramid.i18n.TranslationString or Processor) Error message or processor object.

The models.projects Module

SQLAlchemy-powered model definition for projects.

class publiforge.models.projects.Project(label, description=None, status=None, deadline=None)[source]

SQLAlchemy-powered project model.

classmethod load(project_elt, error_if_exists=True)[source]

Load a project from a XML element.

Parameters:
  • project_elt – (lxml.etree.Element instance) Project XML element.
  • error_if_exists – (boolean, default=True) It returns an error if project already exists.
Returns:

(pyramid.i18n.TranslationString or None) Error message or None.

classmethod team_query(project_id)[source]

Query to retrieve ID, login and name of each member of the project project_id.

Parameters:project_id – (integer) Project ID.
Returns:(sqlalchemy.orm.query.Query instance)
xml(request)[source]

Serialize a project to a XML representation.

Parameters:request – (pyramid.request.Request instance) Current request.
Returns:(lxml.etree.Element)
class publiforge.models.projects.ProjectGroup(project_id, group_id, perm=None)[source]

SQLAlchemy-powered association table between Project and Group.

class publiforge.models.projects.ProjectUser(project_id, user_id, in_menu=False, perm='member', entries=None)[source]

SQLAlchemy-powered association table between Project and User.

The models.processings Module

SQLAlchemy-powered model definition for project processings.

class publiforge.models.processings.Processing(project_id, label, description, processor, output=None, add2pack=None, indirect=False)[source]

SQLAlchemy-powered project processing model.

export_build_variables(proc_elt, processor, pack, values)[source]

Read variable definitions in processor tree and fill variables XML structure for a build.

Parameters:
  • proc_elt – (lxml.etree.Element instance) Processing element that binds the result.
  • processor – (lxml.etree.ElementTree instance) Processor of current processing.
  • pack – (Pack instance) Current pack.
  • values – (dictionary) Variables values.
classmethod load(project_id, processing_elt, check_if_exists=True)[source]

Load a processing from a XML element.

Parameters:
  • processing_elt – (lxml.etree.Element instance) Processing XML element.
  • check_if_exists – (boolean, default=True) Check if processing already exists before inserting.
Returns:

(pyramid.i18n.TranslationString or integer) Error message or integer.

update_sort()[source]

Update sort field of ProcessingFile table.

xml(processor)[source]

Serialize a processing to a XML representation.

Parameters:processor – (lxml.etree.ElementTree instance) Processor of current processing.
Returns:(lxml.etree.Element)
class publiforge.models.processings.ProcessingFile(file_type, path, target=None, sort=None)[source]

SQLAlchemy-powered project processing file model.

class publiforge.models.processings.ProcessingVariable(name, default, visible=None)[source]

SQLAlchemy-powered project processing variable model.

The models.packs Module

SQLAlchemy-powered model definition for project tasks.

class publiforge.models.packs.Pack(project_id, label, description=None, recursive=False, note=None, pack_id=None, created=None, updated=None)[source]

SQLAlchemy-powered project pack model.

classmethod load(project_id, role_dict, processing_dict, task_dict, pack_elt, storage_root=None, pack_id=None)[source]

Load a pack from a XML element.

Parameters:
  • project_id – (integer) Project ID.
  • role_dict – (dictionary) Relationship between XML ID and SQL ID for roles.
  • processing_dict – (dictionary) Relationship between XML ID and SQL ID for processings.
  • task_dict – (dictionary) Relationship between XML ID and SQL ID for tasks.
  • pack_elt – (lxml.etree.Element instance) Pack XML element.
  • storage_root – (string, optional) Full path to storage root directory. If None, files are not checked.
  • pack_id – (integer, optional) Forced pack ID.
Returns:

(pyramid.i18n.TranslationString or Pack) Error message or new Pack object.

update_sort()[source]

Update sort field of PackFile table.

xml()[source]

Serialize a pack to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.packs.PackEvent(project_id, pack_id, task_id, task_label, operator_type, operator_id, operator_label, begin=None)[source]

SQLAlchemy-powered project pack task event model.

xml()[source]

Serialize an event to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.packs.PackFile(file_type, path, target=None, visible=None, sort=None)[source]

SQLAlchemy-powered project pack file model.

class publiforge.models.packs.PackOutput(processing_id, path)[source]

SQLAlchemy-powered project pack output model.

xml()[source]

Serialize an output to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.packs.PackVariable(processing_id, name, value)[source]

SQLAlchemy-powered project pack variable model.

xml()[source]

Serialize a variable to a XML representation.

Returns:(lxml.etree.Element)

The models.tasks Module

SQLAlchemy-powered model definition for project tasks.

class publiforge.models.tasks.Task(project_id, label, description=None, deadline=None, operator_type='auto', operator_id=None)[source]

SQLAlchemy-powered task model.

classmethod load(project_id, role_dict, task_elt)[source]

Load a task from a XML element.

Parameters:
  • project_id – (integer) Project ID.
  • task_elt – (lxml.etree.Element instance) Task XML element.
  • role_dict – (dictionary) Relationship between XML ID and SQL ID for roles.
Returns:

(pyramid.i18n.TranslationString or integer) Error message ort ask ID.

xml()[source]

Serialize a task to a XML representation.

Returns:(lxml.etree.Element)

SQLAlchemy-powered link task model.

classmethod load(project_id, tasks, task_elt)[source]

Load a next task from a XML file.

Parameters:
  • project_id – (integer) Project ID.
  • tasks – (dictionary) Relationship between XML ID and SQL ID for tasks.
  • task_elt – (lxml.etree.Element instance) Task XML element.
xml()[source]

Serialize a next task to a XML representation.

Returns:(lxml.etree.Element)
class publiforge.models.tasks.TaskProcessing(project_id, task_id, processing_id)[source]

SQLAlchemy-powered processing task model.

classmethod load(project_id, task_dict, processing_dict, task_elt)[source]

Load a task processing from a XML file.

Parameters:
  • project_id – (integer) Project ID.
  • task_dict – (dictionary) Relationship between XML ID and SQL ID for tasks.
  • processings – (dictionary) Relationship between XML ID and SQL ID for processings.
  • task_elt – (lxml.etree.Element instance) Task XML element.
xml()[source]

Serialize a task processing to a XML representation.

Returns:(lxml.etree.Element)