Exemple #1
0
def configure_event_listeners(app):
    from changes.signals import register_listener
    from changes.utils.imports import import_string

    for func_path, signal_name in app.config['EVENT_LISTENERS']:
        func = import_string(func_path)
        register_listener(func, signal_name)
Exemple #2
0
def run_event_listener(listener, signal, kwargs):
    # simple check to make sure this is registered
    if not any(l == listener for l, _ in current_app.config['EVENT_LISTENERS']):
        raise SuspiciousOperation('%s is not a registered event listener' % (listener,))

    func = import_string(listener)
    func(**kwargs)
Exemple #3
0
def configure_event_listeners(app):
    from changes.signals import register_listener
    from changes.utils.imports import import_string

    for func_path, signal_name in app.config['EVENT_LISTENERS']:
        func = import_string(func_path)
        register_listener(func, signal_name)
Exemple #4
0
def run_event_listener(listener, signal, kwargs):
    with RCount('run_event_listener'):
        # simple check to make sure this is registered
        if not any(l == listener for l, _ in current_app.config['EVENT_LISTENERS']):
            raise SuspiciousOperation('%s is not a registered event listener' % (listener,))

        func = import_string(listener)
        func(**kwargs)
Exemple #5
0
def run_event_listener(listener, signal, kwargs):
    """
    Actually run the listener

    See fire_signal, which doesn't actually run it
    """
    # simple check to make sure this is registered
    if not any(l == listener for l, _ in current_app.config['EVENT_LISTENERS']):
        raise SuspiciousOperation('%s is not a registered event listener' % (listener,))

    func = import_string(listener)
    func(**kwargs)
Exemple #6
0
    def get_implementation(self, load=True):
        try:
            cls = import_string(self.implementation)
        except Exception:
            return None

        if not load:
            return cls

        try:
            return cls(**self.data)
        except Exception:
            return None
Exemple #7
0
    def get_implementation(self, load=True):
        try:
            cls = import_string(self.implementation)
        except Exception:
            return None

        if not load:
            return cls

        try:
            return cls(**self.data)
        except Exception:
            return None
Exemple #8
0
def run_event_listener(listener, signal, kwargs):
    """
    Actually run the listener

    See fire_signal, which doesn't actually run it
    """
    # simple check to make sure this is registered
    if not any(l == listener
               for l, _ in current_app.config['EVENT_LISTENERS']):
        raise SuspiciousOperation('%s is not a registered event listener' %
                                  (listener, ))

    func = import_string(listener)
    func(**kwargs)
Exemple #9
0
    def get_implementation(self, load=True):
        try:
            cls = import_string(self.implementation)
        except Exception:
            return None

        if not load:
            return cls

        try:
            # XXX(dcramer): It's important that we deepcopy data so any
            # mutations within the BuildStep don't propagate into the db
            return cls(**deepcopy(self.data))
        except Exception:
            return None
Exemple #10
0
    def get_implementation(self, load=True):
        try:
            cls = import_string(self.implementation)
        except Exception:
            return None

        if not load:
            return cls

        try:
            # XXX(dcramer): It's important that we deepcopy data so any
            # mutations within the BuildStep don't propagate into the db
            return cls(**deepcopy(self.data))
        except Exception:
            return None
Exemple #11
0
 def get_storage(self):
     storage = import_string(self.storage)
     return storage(**self.storage_options)
Exemple #12
0
 def get_implementation(self):
     return import_string(self.implementation)(**self.data)
Exemple #13
0
 def get_storage(self):
     storage = import_string(self.storage)
     return storage(**self.storage_options)