- The documentation of ``pyramid.events.subscriber`` indicated that using it
as a decorator with no arguments like this::
@subscriber()
def somefunc(event):
pass
Would register ``somefunc`` to receive all events sent via the registry,
but this was untrue. Instead, it would receive no events at all. This has
now been fixed and the code matches the documentation. See also
https://github.com/Pylons/pyramid/issues/386
Closes #386
| | |
| | | |
| | | - Use the ``waitress`` WSGI server instead of ``wsgiref`` in scaffolding. |
| | | |
| | | Bug Fixes |
| | | --------- |
| | | |
| | | - The documentation of ``pyramid.events.subscriber`` indicated that using it |
| | | as a decorator with no arguments like this:: |
| | | |
| | | @subscriber() |
| | | def somefunc(event): |
| | | pass |
| | | |
| | | Would register ``somefunc`` to receive all events sent via the registry, |
| | | but this was untrue. Instead, it would receive no events at all. This has |
| | | now been fixed and the code matches the documentation. See also |
| | | https://github.com/Pylons/pyramid/issues/386 |
| | | |
| | | 1.3a3 (2011-12-21) |
| | | ================== |
| | | |
| | |
| | | import venusian |
| | | |
| | | from zope.interface import implementer |
| | | from zope.interface import ( |
| | | implementer, |
| | | Interface |
| | | ) |
| | | |
| | | from pyramid.interfaces import ( |
| | | IContextFound, |
| | |
| | | def mysubscriber(event): |
| | | event.request.foo = 1 |
| | | |
| | | More than one event type can be passed as a construtor argument. The |
| | | More than one event type can be passed as a constructor argument. The |
| | | decorated subscriber will be called for each event type. |
| | | |
| | | .. code-block:: python |
| | |
| | | |
| | | def register(self, scanner, name, wrapped): |
| | | config = scanner.config |
| | | for iface in self.ifaces: |
| | | for iface in self.ifaces or (Interface,): |
| | | config.add_subscriber(wrapped, iface) |
| | | |
| | | def __call__(self, wrapped): |
| | |
| | | dec.register(scanner, None, foo) |
| | | self.assertEqual(config.subscribed, [(foo, IFoo), (foo, IBar)]) |
| | | |
| | | def test_register_none_means_all(self): |
| | | from zope.interface import Interface |
| | | dec = self._makeOne() |
| | | def foo(): pass |
| | | config = DummyConfigurator() |
| | | scanner = Dummy() |
| | | scanner.config = config |
| | | dec.register(scanner, None, foo) |
| | | self.assertEqual(config.subscribed, [(foo, Interface)]) |
| | | |
| | | def test_register_objectevent(self): |
| | | from zope.interface import Interface |
| | | class IFoo(Interface): pass |