[Zope3-checkins] CVS: Zope3/src/zope/component - __init__.py:1.17
presentation.py:1.6
michael dunstan
michael at elyt.com
Mon Feb 9 02:41:51 EST 2004
Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv14924/src/zope/component
Modified Files:
__init__.py presentation.py
Log Message:
Add subscription adapters (partial adapters that return all possible factories
that match your query).
=== Zope3/src/zope/component/__init__.py 1.16 => 1.17 ===
--- Zope3/src/zope/component/__init__.py:1.16 Fri Dec 19 11:53:20 2003
+++ Zope3/src/zope/component/__init__.py Mon Feb 9 02:41:20 2004
@@ -121,6 +121,38 @@
queryNamedAdapter = hookable(queryNamedAdapter)
+def queryMultiAdapter(objects, interface, context, name=u'', default=None):
+ try:
+ adapters = getService(context, Adapters)
+ except ComponentLookupError:
+ # Oh blast, no adapter service. We're probably just running from a test
+ return default
+
+ return adapters.queryMultiAdapter(objects, interface, name, default)
+
+def querySubscriptionAdapter(object, interface, name, default=(),
+ context=None):
+ if context is None:
+ context = object
+ try:
+ adapters = getService(context, Adapters)
+ except ComponentLookupError:
+ # Oh blast, no adapter service. We're probably just running from a test
+ return default
+
+ return adapters.querySubscriptionAdapter(object, interface, name, default)
+
+def querySubscriptionMultiAdapter(objects, interface, context, name=u'',
+ default=()):
+ try:
+ adapters = getService(context, Adapters)
+ except ComponentLookupError:
+ # Oh blast, no adapter service. We're probably just running from a test
+ return default
+
+ return adapters.querySubscriptionMultiAdapter(objects, interface, name,
+ default)
+
# Factory service
def createObject(context, name, *args, **kwargs):
=== Zope3/src/zope/component/presentation.py 1.5 => 1.6 ===
--- Zope3/src/zope/component/presentation.py:1.5 Thu Jan 29 12:36:49 2004
+++ Zope3/src/zope/component/presentation.py Mon Feb 9 02:41:20 2004
@@ -202,12 +202,16 @@
>>> match = s.getRegisteredMatching(request=IRequest)
>>> match.keys()
['custom']
- >>> match['custom'][0] == \
+ >>> matcheditems = list(match['custom'])
+ >>> matcheditems.sort(lambda x,y: cmp(x[3],y[3]))
+ >>> matcheditems[0] == \
... (IContact, ITraverse, (IRequest,), u'', [Traverser])
True
>>> match = s.getRegisteredMatching(IContact, IRequest)
- >>> match['custom'][0] == \
+ >>> matcheditems = list(match['custom'])
+ >>> matcheditems.sort(lambda x,y: cmp(x[3],y[3]))
+ >>> matcheditems[0] == \
... (IContact, ITraverse, (IRequest,), u'', [Traverser])
True
More information about the Zope3-Checkins
mailing list