Python sqlalchemy.event.Events() Examples

The following are 21 code examples of sqlalchemy.event.Events(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy.event , or try the search function .
Example #1
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def _wrapped_fixture(self):
        class TargetEvents(event.Events):
            @classmethod
            def _listen(cls, event_key):
                fn = event_key._listen_fn

                def adapt(value):
                    fn("adapted " + value)

                event_key = event_key.with_wrapper(adapt)

                event_key.base_listen()

            def event_one(self, x):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        return Target 
Example #2
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def setUp(self):
        class TargetEvents(event.Events):
            def event_one(self, target, arg):
                pass

        class BaseTarget(object):
            dispatch = event.dispatcher(TargetEvents)

        class SubTarget(BaseTarget):
            _sa_propagate_class_events = False

            def __init__(self, parent):
                self.dispatch = self.dispatch._join(parent.dispatch)

        self.BaseTarget = BaseTarget
        self.SubTarget = SubTarget 
Example #3
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def _wrapped_fixture(self):
        class TargetEvents(event.Events):
            @classmethod
            def _listen(cls, event_key):
                fn = event_key._listen_fn

                def adapt(*args):
                    fn(*["adapted %s" % arg for arg in args])

                event_key = event_key.with_wrapper(adapt)

                event_key.base_listen()

            def event_one(self, x, y):
                pass

            def event_five(self, x, y, z, q):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        return Target 
Example #4
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def setUp(self):
        class TargetEventsOne(event.Events):
            @event._legacy_signature("0.9", ["x", "y"])
            def event_three(self, x, y, z, q):
                pass

            @event._legacy_signature("0.9", ["x", "y", "**kw"])
            def event_four(self, x, y, z, q, **kw):
                pass

            @event._legacy_signature(
                "0.9", ["x", "y", "z", "q"], lambda x, y: (x, y, x + y, x * y)
            )
            def event_six(self, x, y):
                pass

        class TargetOne(object):
            dispatch = event.dispatcher(TargetEventsOne)

        self.TargetOne = TargetOne 
Example #5
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def setUp(self):
        class TargetEventsOne(event.Events):
            def event_one(self, x, y):
                pass

        class TargetEventsTwo(event.Events):
            def event_one(self, x, y):
                pass

        class TargetOne(object):
            dispatch = event.dispatcher(TargetEventsOne)

        class TargetTwo(object):
            dispatch = event.dispatcher(TargetEventsTwo)

        self.TargetOne = TargetOne
        self.TargetTwo = TargetTwo 
Example #6
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def setUp(self):
        class TargetEvents(event.Events):
            @classmethod
            def _accept_with(cls, target):
                if target == "one":
                    return Target
                else:
                    return None

            def event_one(self, x, y):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        self.Target = Target 
Example #7
Source File: test_events.py    From sqlalchemy with MIT License 6 votes vote down vote up
def setUp(self):
        class TargetEvents(event.Events):
            @classmethod
            def _listen(cls, event_key, add=False):
                fn = event_key.fn
                if add:

                    def adapt(x, y):
                        fn(x + y)

                    event_key = event_key.with_wrapper(adapt)

                event_key.base_listen()

            def event_one(self, x, y):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        self.Target = Target 
Example #8
Source File: events.py    From android_universal with MIT License 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch 
Example #9
Source File: events.py    From jbox with MIT License 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch 
Example #10
Source File: events.py    From moviegrabber with GNU General Public License v3.0 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False 
Example #11
Source File: events.py    From jarvis with GNU General Public License v2.0 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch 
Example #12
Source File: test_events.py    From sqlalchemy with MIT License 5 votes vote down vote up
def _fixture(self):
        class TargetEvents(event.Events):
            def event_one(self, x, y):
                pass

            def event_two(self, x):
                pass

            def event_three(self, x):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        return Target 
Example #13
Source File: test_events.py    From sqlalchemy with MIT License 5 votes vote down vote up
def setUp(self):
        class TargetEvents(event.Events):
            def event_one(self, arg):
                pass

            def event_two(self, arg):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        self.Target = Target 
Example #14
Source File: test_events.py    From sqlalchemy with MIT License 5 votes vote down vote up
def setUp(self):
        class TargetEvents(event.Events):
            def some_event(self, x, y):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        self.Target = Target 
Example #15
Source File: test_events.py    From sqlalchemy with MIT License 5 votes vote down vote up
def _fixture(self):
        class TargetEventsOne(event.Events):
            def event_one(self, x, y):
                pass

            def event_two(self, x, y, **kw):
                pass

            def event_five(self, x, y, z, q):
                pass

        class TargetOne(object):
            dispatch = event.dispatcher(TargetEventsOne)

        return TargetOne 
Example #16
Source File: test_events.py    From sqlalchemy with MIT License 5 votes vote down vote up
def setUp(self):
        class TargetEvents(event.Events):
            def event_one(self, x, y):
                pass

            def event_two(self, x):
                pass

            def event_three(self, x):
                pass

        class Target(object):
            dispatch = event.dispatcher(TargetEvents)

        self.Target = Target 
Example #17
Source File: events.py    From sqlalchemy with MIT License 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch 
Example #18
Source File: events.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False 
Example #19
Source File: events.py    From pyRevit with GNU General Public License v3.0 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch 
Example #20
Source File: events.py    From planespotter with MIT License 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch 
Example #21
Source File: events.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def _set_dispatch(cls, dispatch_cls):
        dispatch = event.Events._set_dispatch(cls, dispatch_cls)
        dispatch_cls._active_history = False
        return dispatch