Includes Reference

The includes Module

Collection of functionalities with an includeme() function to be used by the Pyramid configurator or in the INI file.

chrysalio.includes.load_includes(configurator: Configurator, includes: list | None = None)[source]

Load modules with an includeme() function and fill configurator.registry['modules'] ordered dictionary.

Parameters:
  • configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

  • includes (list) – (optional) List of hard coding includes.

The includes.themes Module

Theme management.

chrysalio.includes.themes.includeme(configurator: Configurator)[source]

Function to include themes.

Parameters:

configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

chrysalio.includes.themes.load_themes(configurator: Configurator)[source]

Load available themes in registry.

Parameters:

configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

Set into registry a tuple such as (default_theme, theme_dict) where theme_dict is a dictionary like {'theme_id': theme_info…}. theme_info is a dictionary with keys path, layout, login,…

chrysalio.includes.themes.create_default_theme(configurator: Configurator, package: str)[source]

If the theme management is not activated, it creates a default theme in registry.

Parameters:
  • configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

  • package (str) – Name of the calling package.

chrysalio.includes.themes.theme_template(request: Request, template_id: str) str | None[source]

Retrieve the absolute file path of the file template_id of the current theme.

Parameters:
  • request – pyramid.request.Request`

  • request – Current request.

  • template_id (str) – ID of the file to retrieve.

Return type:

str

Returns:

Absolute path to the template file or None.

chrysalio.includes.themes.theme_static_prefix(request: Request) str[source]

Return the URL prefix for the current theme.

Parameters:
  • request – pyramid.request.Request`

  • request – Current request.

Return type:

str A string such as /theme/alternative for theme Alternative or ‘’.

chrysalio.includes.themes.theme_has_static(request: Request, static_id: str) bool[source]

Return True if the descriminator exists in static views.

Parameters:
  • request – pyramid.request.Request`

  • request – Current request.

  • static_id (str) – ID of static view to check.

Return type:

bool

The includes.cache Module

Cache functionality.

chrysalio.includes.cache.includeme(configurator)[source]

Function to include cache functionnality based on registry for global cache and session for user cache.

Parameters:

configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

class chrysalio.includes.cache.CacheUser(settings)[source]

Class to manage a private cache for a user based on session.

set(request, key, value, namespace='', region=None, expire=None)[source]

Set value into the cache.

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

  • key (str) – Key of value to retrieve.

  • value – The value associated with the key or None.

  • namespace (str) – (default=’’) Cache namespace.

  • region (str) – (optional) Beaker cache region.

  • expire (int) – (optional) Special expiration.

get(request, key, namespace='')[source]

Get value from the cache.

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

  • key (str) – Key of value to retrieve.

  • namespace (str) – (default=’’) Cache namespace.

Returns:

The value associated with the key or None.

clear(request, key=None, namespace='')[source]

Clear a key/value or the entire namespace namespace.

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

  • key (str) – (optional) Key of value to remove.

  • namespace (str) – (default=’’) Cache namespace.

classmethod purge(request, namespace=None)[source]

Purge expired entries.

Parameters:
chrysalio.includes.cache.cache_user_access(namespace_prefix, region=None)[source]

A decorator to retrieve in the user cache the result of an access method whose the two first arguments are request and item. item must have a uid attribute.

Parameters:
  • namespace_prefix (str) – Prefix of the cache namespace.

  • region (str) – (optional) Name of region.

class chrysalio.includes.cache.CacheGlobal(settings)[source]

Class to manage a global cache based on Beaker cache.

Parameters:

settings (dict) – Pyramid settings.

set(key, value, namespace='', region=None, **kwargs)[source]

Set value into the cache.

Parameters:
  • key (str) – Key of value to retrieve.

  • value – The value associated with the key or None.

  • namespace (str) – (default=’’) Cache namespace.

  • region (str) – (optional) Beaker cache region.

  • kwargs (dict) – Keyworded arguments.

get(key, namespace='', region=None, **kwargs)[source]

Get value from the cache.

Parameters:
  • key (str) – Key of value to retrieve.

  • namespace (str) – (default=’’) Cache namespace.

  • region (str) – (optional) Beaker cache region.

  • kwargs (dict) – Keyworded arguments.

Returns:

The value associated with the key or None.

clear(key=None, namespace='', region=None)[source]

Clear a key/value or the entire namespace namespace.

Parameters:
  • key (str) – (optional) Key of value to remove.

  • namespace (str) – (default=’’) Cache namespace.

  • region (str) – (optional) Beaker cache region.

initialize(namespace='', region=None)[source]

Clear a key/value or the entire namespace namespace and set the time of creation.

Parameters:
  • namespace (str) – (default=’’) Cache namespace.

  • region (str) – (optional) Beaker cache region.

chrysalio.includes.cache.cache_global_item(namespace_prefix, region=None, access_function=None)[source]

A decorator to retrieve in the global cache the result of a creation method whose the two first arguments are request and item_id. The calling class must have a _<item>s attribute where <item> is the class name in lower case. If access_function is not None, the access rights are checked.

Parameters:
  • namespace_prefix (str) – Prefix of the cache namespace.

  • region (tuple) – (optional) Name of region.

  • access_function – (optional) A function to retrieve the access tuple.

chrysalio.includes.cache.cache_global_value(key, namespace_prefix, region=None)[source]

A decorator to retrieve in the global cache the result of a computing method whose the first argument is request. The class of the method must have an uid attribute.

Parameters:
  • key (str) – Key of the value to retrieve.

  • namespace_prefix (str) – Prefix of the cache namespace.

  • region (str) – (optional) Name of region.

chrysalio.includes.cache.cache_namespace(namespace_prefix, item_id)[source]

Return a namespace for the item item_id.

Parameters:
  • namespace (str) – Cache namespace.

  • item_id (str) – ID of the item.

Return type:

str

The includes.clipboard Module

Clipboard management.

chrysalio.includes.clipboard.includeme(configurator: Configurator)[source]

Function to include the clipboard.

Parameters:

configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

class chrysalio.includes.clipboard.NavClipboard(uid: str, label: str, button_class: str, area: list | None)[source]

Entry for clipboard.

nav_button(request: Request, class_: str | None = None) str[source]

Return the HTML of the button to open the clipboard.

class chrysalio.includes.clipboard.Clipboard(area: tuple[str, ...] | None = None)[source]

Class to manage clipboard and clipboard panel.

See: lib.panel.Panel

nav_entry

alias of NavClipboard

classmethod register(registry: Registry, panel_class, area: tuple[str, ...] | None = None) Panel | None[source]

Method to register the panel and possibly add it to a navigation menu.

See: lib.panel.Panel.register()

classmethod is_empty(request: Request) bool[source]

Return True if the clipboard is empty.

Parameters:

request (pyramid.request.Request) – Current request.

Return type:

bool

classmethod entries(request: Request) list[source]

Return the list of entries.

Parameters:

request (pyramid.request.Request) – Current request.

Return type:

list

classmethod push(request: Request, domain: str, cut: bool, data, preview: str)[source]

Push a new entry in the clipboard buffer.

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

  • domain (str) – Domain of the entry (ex.: 'warehouse/file').

  • cut (bool) – True if it is a cut operation.

  • data – Content of this entry. It depends on the domain.

  • preview (helpers.literal.Literal) – Representation of the entry in the clipboard.

classmethod selection(request: Request, domains: list) list[source]

Return entries selected in the clipboard and compatible with almost one domain of domains.

Parameters:
Return type:

list

The includes.modules Module

Modules management.

chrysalio.includes.modules.includeme(configurator)[source]

Function to include modules functionality.

Parameters:

configurator (pyramid.config.Configurator) – Object used to do configuration declaration within the application.

The includes.modules.models Module

SQLAlchemy-powered model definitions for modules.

class chrysalio.includes.modules.models.DBModule(**kwargs)[source]

SQLAlchemy-powered module class.

classmethod table4view(request)[source]

Generate the modules table.

Parameters:

request (pyramid.request.Request) – Current request.

Return type:

helpers.literal.Literal

classmethod settings_schema(request)[source]

Return a Colander schema to edit modules.

Parameters:

request (pyramid.request.Request) – Current request.

Return type:

tuple

Returns:

A tuple such as (schema, defaults).

classmethod table4edit(request, form)[source]

Generate the modules table for edition.

Parameters:
Return type:

helpers.literal.Literal

The includes.modules.views Module

View callables.

class chrysalio.includes.modules.views.ModulesView(request)[source]

Class to manage modules.

Parameters:

request (pyramid.request.Request) – Current request.

view()[source]

Show modules.

edit()[source]

Edit modules.