Python sqlalchemy.event.dispatcher() Examples
The following are 13
code examples of sqlalchemy.event.dispatcher().
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 |
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 #2
Source File: test_events.py From sqlalchemy with MIT License | 6 votes |
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 #3
Source File: test_events.py From sqlalchemy with MIT License | 6 votes |
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 #4
Source File: test_events.py From sqlalchemy with MIT License | 6 votes |
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 #5
Source File: test_events.py From sqlalchemy with MIT License | 6 votes |
def setUp(self): class TargetEvents(event.Events): def event_one(self, target, arg): pass class BaseTarget(object): dispatch = event.dispatcher(TargetEvents) class TargetFactory(BaseTarget): def create(self): return TargetElement(self) class TargetElement(BaseTarget): def __init__(self, parent): self.dispatch = self.dispatch._join(parent.dispatch) def run_event(self, arg): list(self.dispatch.event_one) self.dispatch.event_one(self, arg) self.BaseTarget = BaseTarget self.TargetFactory = TargetFactory self.TargetElement = TargetElement
Example #6
Source File: test_events.py From sqlalchemy with MIT License | 6 votes |
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 #7
Source File: test_extendedattr.py From sqlalchemy with MIT License | 6 votes |
def test_subclassed(self): class MyEvents(events.InstanceEvents): pass class MyClassManager(instrumentation.ClassManager): dispatch = event.dispatcher(MyEvents) instrumentation.instrumentation_finders.insert( 0, lambda cls: MyClassManager ) class A(object): pass register_class(A) manager = instrumentation.manager_of_class(A) assert issubclass(manager.dispatch._events, MyEvents)
Example #8
Source File: test_events.py From sqlalchemy with MIT License | 5 votes |
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 #9
Source File: test_events.py From sqlalchemy with MIT License | 5 votes |
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 #10
Source File: test_events.py From sqlalchemy with MIT License | 5 votes |
def setUp(self): class TargetEventsOne(event.Events): def event_one(self, x, y): pass class TargetOne(object): dispatch = event.dispatcher(TargetEventsOne) self.TargetOne = TargetOne
Example #11
Source File: test_events.py From sqlalchemy with MIT License | 5 votes |
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 #12
Source File: test_events.py From sqlalchemy with MIT License | 5 votes |
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 #13
Source File: test_events.py From sqlalchemy with MIT License | 5 votes |
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