subscriber directive doesn't allow declaring provided interface in Python

Bug #1025539 reported by Thomas Lotze
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zope.component
Won't Fix
Undecided
Unassigned

Bug Description

The docs of zope.component (zcml.rst) say:

"""
Like the <adapter /> directive, the <subscriber /> directive can
figure out from the in-line Python declaration (using
``zope.component.adapts()`` or ``zope.component.adapter()``) what the
subscriber should be registered for:
"""

However, the examples following that piece of text don't demonstrate something like <subscriber factory="foo.bar" /> (with foo.bar being a declared in Python code to implement some unambiguous interface). In fact, adding the following test (analogous to Test_adapter.test_no_for__no_provides_factory_adapts_factory_implements) to zope.component.tests.test_zcml.Test_subscriber will result in a failure:

    def test_no_for__no_provides_subscriber_adapts_subscriber_implements(self):
        from zope.interface import Interface
        from zope.interface import implementer
        from zope.component._declaration import adapter
        from zope.component.zcml import subscriber
        class IFoo(Interface):
            pass
        @adapter(Interface)
        @implementer(IFoo)
        class _Factory(object):
            def __init__(self, context):
                self.context = context
        _cfg_ctx = _makeConfigContext()
        self._callFUT(_cfg_ctx, factory=_Factory)
        self.assertEqual(len(_cfg_ctx._actions), 3)
        self.assertEqual(_cfg_ctx._actions[0][0], ())
        # Register the adapter
        action = _cfg_ctx._actions[0][1]
        self.assertEqual(action['callable'], subscriber)
        self.assertEqual(action['discriminator'],
                         ('subscriber', (Interface,), IFoo, ''))
        self.assertEqual(action['args'],
                         ('registerSubscriber', _Factory, (Interface,), IFoo,
                          '', 'TESTING'))

Revision history for this message
Tres Seaver (tseaver) wrote :
Changed in zope.component:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.