isomer.component module

Configurable Component

Contains

Systemwide configurable component definition. Stores configuration either in database or as json files. Enables editing of configuration through frontend.

See also

Provisions

class BaseMeta[source]

Bases: object

Isomer Base Component Class

context = None
exception ComponentDisabled[source]

Bases: Exception

class ConfigurableComponent(uniquename, *args, **kwargs)[source]

Bases: isomer.component.ConfigurableMeta, circuits.core.components.Component

Configurable component for default Isomer modules

__init__(uniquename, *args, **kwargs)[source]

Check for configuration issues and instantiate a component

class ConfigurableController(uniquename, *args, **kwargs)[source]

Bases: isomer.component.ConfigurableMeta, circuits.web.controllers.Controller

Configurable controller for direct web access

__init__(uniquename, *args, **kwargs)[source]

Check for configuration issues and instantiate a component

class ConfigurableMeta(uniquename, no_db=False, *args, **kwargs)[source]

Bases: isomer.component.LoggingMeta

Meta class to add configuration capabilities to circuits objects

__init__(uniquename, no_db=False, *args, **kwargs)[source]

Check for configuration issues and instantiate a component

configform = []
configprops = {}
register(*args)[source]

Register a configurable component in the configuration schema store

reload_configuration(event)[source]

Event triggered configuration reload

unregister(*args)[source]

Removes the unique name from the systems unique name list

class ExampleComponent(*args, **kwargs)[source]

Bases: isomer.component.ConfigurableComponent

Exemplary component to demonstrate basic component usage

__init__(*args, **kwargs)[source]

Show how the component initialization works and test this by adding a log statement.

configprops = {'setting': {'default': 'Yay', 'description': 'Some string setting.', 'title': 'Some Setting', 'type': 'string'}}
class FrontendMeta(uniquename=None, *args, **kwargs)[source]

Bases: isomer.component.LoggingMeta

Meta component for frontend-only modules

There is nothing to configure here.

register(*_)[source]

Mock command, does not do anything except log invocation

class LoggingComponent(uniquename, *args, **kwargs)[source]

Bases: isomer.component.LoggingMeta, circuits.core.components.Component

Logging capable component for simple Isomer components

__init__(uniquename, *args, **kwargs)[source]

Check for configuration issues and instantiate a component

class LoggingMeta(uniquename=None, *args, **kwargs)[source]

Bases: isomer.component.BaseMeta

Base class for all components that adds naming and logging functionality

__init__(uniquename=None, *args, **kwargs)[source]

Check for configuration issues and instantiate a component

log(*args, **kwargs)[source]

Log a statement from this component

names = []
handler(*names, **kwargs)[source]

Creates an Event Handler

This decorator can be applied to methods of classes derived from circuits.core.components.BaseComponent. It marks the method as a handler for the events passed as arguments to the @handler decorator. The events are specified by their name.

The decorated method’s arguments must match the arguments passed to the circuits.core.events.Event on creation. Optionally, the method may have an additional first argument named event. If declared, the event object that caused the handler to be invoked is assigned to it.

By default, the handler is invoked by the component’s root Manager for events that are propagated on the channel determined by the BaseComponent’s channel attribute. This may be overridden by specifying a different channel as a keyword parameter of the decorator (channel=...).

Keyword argument priority influences the order in which handlers for a specific event are invoked. The higher the priority, the earlier the handler is executed.

If you want to override a handler defined in a base class of your component, you must specify override=True, else your method becomes an additional handler for the event.

Return value

Normally, the results returned by the handlers for an event are simply collected in the circuits.core.events.Event’s value attribute. As a special case, a handler may return a types.GeneratorType. This signals to the dispatcher that the handler isn’t ready to deliver a result yet. Rather, it has interrupted it’s execution with a yield None statement, thus preserving its current execution state.

The dispatcher saves the returned generator object as a task. All tasks are reexamined (i.e. their next() method is invoked) when the pending events have been executed.

This feature avoids an unnecessarily complicated chaining of event handlers. Imagine a handler A that needs the results from firing an event E in order to complete. Then without this feature, the final action of A would be to fire event E, and another handler for an event SuccessE would be required to complete handler A’s operation, now having the result from invoking E available (actually it’s even a bit more complicated).

Using this “suspend” feature, the handler simply fires event E and then yields None until e.g. it finds a result in E’s value attribute. For the simplest scenario, there even is a utility method circuits.core.manager.Manager.callEvent() that combines firing and waiting.