def schema(schema_cls): """ Register a schema. """ on_resolve(PubSubMessageSchemaRegistry, register_schema, schema_cls) return schema_cls
def decorator(func): on_resolve(PubSubMessageSchemaRegistry, register_schema, schema_cls) on_resolve(SQSMessageHandlerRegistry, register_handler, schema_cls, func) return func
def foo_hook(foo, value): foo.callbacks.append(value) @binding("foo") class Foo: def __init__(self, graph): self.callbacks = [] @binding("bar") def new_foo(graph): return Foo(graph) on_resolve(Foo, foo_hook, "baz") class TestHooks: """ Test hook invocations. """ def test_on_resolve_foo_once(self): """ Resolving Foo calls the hook. """ graph = create_object_graph("test") graph.use("foo") graph.lock()
foo.callbacks.append(value) @binding("foo") class Foo(object): def __init__(self, graph): self.callbacks = [] @binding("bar") def new_foo(graph): return Foo(graph) on_resolve(Foo, foo_hook, "baz") class TestHooks(object): """ Test hook invocations. """ def test_on_resolve_foo_once(self): """ Resolving Foo calls the hook. """ graph = create_object_graph("test") graph.use("foo") graph.lock()
class Foo: def __init__(self, graph): self.callbacks = [] @binding("subfoo") class SubFoo(Foo): pass @binding("bar") def new_foo(graph): return Foo(graph) on_resolve(Foo, foo_hook, "baz") on_resolve(SubFoo, foo_hook, "qux") class TestHooks: """ Test hook invocations. """ def test_on_resolve_foo_once(self): """ Resolving Foo calls the hook. """ graph = create_object_graph("test") graph.use("foo")