[Zope3-checkins] SVN: Zope3/branches/3.3/ - Fixed a bug on
unregistering handlers. When multiple handlers for one
Christian Theune
ct at gocept.com
Thu Aug 17 17:07:02 EDT 2006
Log message for revision 69628:
- Fixed a bug on unregistering handlers. When multiple handlers for one
specification where registered, all of them would be removed when only
a single one was unregistered.
Changed:
U Zope3/branches/3.3/doc/CHANGES.txt
U Zope3/branches/3.3/src/zope/component/registry.py
U Zope3/branches/3.3/src/zope/component/tests.py
-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt 2006-08-17 21:05:47 UTC (rev 69627)
+++ Zope3/branches/3.3/doc/CHANGES.txt 2006-08-17 21:07:01 UTC (rev 69628)
@@ -16,6 +16,10 @@
Bugfixes
+ - Fixed a bug on unregistering handlers. When multiple handlers for one
+ specification where registered, all of them would be removed when only
+ a single one was unregistered.
+
- Fixed issue 507: Default configuration exposes template code and
paths. Developer mode is now switched off by default and a warning is
issued if it is turned on.
Modified: Zope3/branches/3.3/src/zope/component/registry.py
===================================================================
--- Zope3/branches/3.3/src/zope/component/registry.py 2006-08-17 21:05:47 UTC (rev 69627)
+++ Zope3/branches/3.3/src/zope/component/registry.py 2006-08-17 21:07:01 UTC (rev 69628)
@@ -336,7 +336,7 @@
return False
self._handler_registrations[:] = new
- self.adapters.unsubscribe(required, None)
+ self.adapters.unsubscribe(required, None, factory)
zope.event.notify(interfaces.Unregistered(
HandlerRegistration(self, required, name, factory, '')
Modified: Zope3/branches/3.3/src/zope/component/tests.py
===================================================================
--- Zope3/branches/3.3/src/zope/component/tests.py 2006-08-17 21:05:47 UTC (rev 69627)
+++ Zope3/branches/3.3/src/zope/component/tests.py 2006-08-17 21:07:01 UTC (rev 69628)
@@ -911,7 +911,7 @@
>>> r2.lookup((), IFoo, '2')
>>> base.register((), IFoo, '2', Foo('2'))
-
+
>>> r1.lookup((), IFoo, '2')
Foo('2')
@@ -925,6 +925,32 @@
"""
+
+def test_multi_handler_unregistration():
+ """There was a bug where multiple handlers for the same required specification
+ would all be removed when one of them was unregistered:
+
+ >>> class I(zope.interface.Interface):
+ ... pass
+ >>> def factory1(event):
+ ... print "| Factory 1 is here"
+ >>> def factory2(event):
+ ... print "| Factory 2 is here"
+ >>> class Event(object):
+ ... zope.interface.implements(I)
+ >>> from zope.component.registry import Components
+ >>> registry = Components()
+ >>> registry.registerHandler(factory1, [I,])
+ >>> registry.registerHandler(factory2, [I,])
+ >>> registry.handle(Event())
+ | Factory 1 is here
+ | Factory 2 is here
+ >>> registry.unregisterHandler(factory1, [I,])
+ True
+ >>> registry.handle(Event())
+ | Factory 2 is here
+ """
+
class StandaloneTests(unittest.TestCase):
def testStandalone(self):
import subprocess
More information about the Zope3-Checkins
mailing list