[Zope3-checkins] SVN: Zope3/trunk/ Fixed a bug in the adapter
registry that would prevent `dict`-derived
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Dec 20 18:36:16 EST 2004
Log message for revision 28659:
Fixed a bug in the adapter registry that would prevent `dict`-derived
utilites from being retrieved correctly.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/interface/adapter.py
U Zope3/trunk/src/zope/interface/adapter.txt
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2004-12-20 22:58:33 UTC (rev 28658)
+++ Zope3/trunk/doc/CHANGES.txt 2004-12-20 23:36:15 UTC (rev 28659)
@@ -254,6 +254,9 @@
Bug Fixes
+ - Fixed a bug in the adapter registry that would prevent `dict`-derived
+ utilites from being retrieved correctly.
+
- Resolved issue 304 (Slash involve dbname). We require now that all
values in a DSN are properly URL-encoded, so that all values can
contain any special character, except for the hostname and the port.
Modified: Zope3/trunk/src/zope/interface/adapter.py
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.py 2004-12-20 22:58:33 UTC (rev 28658)
+++ Zope3/trunk/src/zope/interface/adapter.py 2004-12-20 23:36:15 UTC (rev 28659)
@@ -196,17 +196,18 @@
# Now flatten with mappings to tuples
for key, v in implied.iteritems():
- if isinstance(key, tuple) and key[0] == 's':
- # subscriptions
- if isinstance(v, dict):
- implied[key] = v.items()
- else:
- byname = v
- for name, value in byname.iteritems():
- if isinstance(value, dict):
- # We have {with -> value}
- # convert it to sorted [(with, value]
- byname[name] = orderwith(value)
+ if isinstance(key, tuple):
+ if key[0] == 's':
+ # subscriptions
+ if isinstance(v, dict):
+ implied[key] = v.items()
+ else:
+ byname = v
+ for name, value in byname.iteritems():
+ if isinstance(value, dict):
+ # We have {with -> value}
+ # convert it to sorted [(with, value]
+ byname[name] = orderwith(value)
self.get = implied.get
Modified: Zope3/trunk/src/zope/interface/adapter.txt
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.txt 2004-12-20 22:58:33 UTC (rev 28658)
+++ Zope3/trunk/src/zope/interface/adapter.txt 2004-12-20 23:36:15 UTC (rev 28659)
@@ -244,6 +244,17 @@
>>> registry.lookup([zope.interface.implementedBy(C2)], IP1, '')
'C21'
+Dict adapters
+-------------
+
+At some point it was impossible to register dictionary-based adapters due a
+bug. Let's make sure this works now:
+
+ >>> adapter = {}
+ >>> registry.register((), IQ, '', adapter)
+ >>> registry.lookup((), IQ, '') is adapter
+ True
+
Unregistering
-------------
More information about the Zope3-Checkins
mailing list