Example #1
0
 def actions(self):
     if self._actions is None:
         self._actions = []
         for listener, action in self._listeners:
             try:
                 mod_name, obj_name = listener.rsplit('.', 1)
             except AttributeError:
                 klass = listener
             else:
                 klass = import_object(mod_name, obj_name)
             self._actions.append((action, klass))
     return self._actions
Example #2
0
def _setup_events(conf):
    """Setup the events defined in the settings."""
    events = {}
    for name in conf.keys():
        events[name] = Event(name=name)
        for listener in conf[name]:
            action = 'run'
            if ':' in listener:
                listener, action = listener.rsplit(':')
            mod_name, obj_name = listener.rsplit('.', 1)
            klass = import_object(mod_name, obj_name)
            events[name].add_listener(klass, action)

    # Add events to module scope.
    globals().update(events)
Example #3
0
# -*- coding: utf-8 -*-

"""
Base classes for possible actions taken on events.
"""

from events.conf import settings
from events.utils import import_object


_mod_name, _obj_name = settings.EVENTS_STORE_OBJECT.rsplit('.', 1)
_obj = import_object(_mod_name, _obj_name)
if callable(_obj):
    _store = _obj()
else:
    _store = _obj


class Action(object):
    """
    Base class of the hierarchy.

    The developer is expected to provide the necessary method(s) with
    the actual code to run.

    """

    _valid_actions = ['run']

    def __init__(self, action):
        if action not in self._valid_actions:
Example #4
0
# -*- coding: utf-8 -*-
"""
Base classes for possible actions taken on events.
"""

from __future__ import unicode_literals

from events.conf import EVENTS_STORE_OBJECT
from events.utils import import_object

_mod_name, _obj_name = EVENTS_STORE_OBJECT.rsplit('.', 1)
_obj = import_object(_mod_name, _obj_name)
if callable(_obj):
    _store = _obj()
else:
    _store = _obj


class Action(object):
    """
    Base class of the hierarchy.

    The developer is expected to provide the necessary method(s) with
    the actual code to run.

    """

    _valid_actions = ['run']

    def __init__(self, action):
        if action not in self._valid_actions: