[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/ComponentArchitecture - meta.zcml:1.2 metaConfigure.py:1.5
Jim Fulton
jim@zope.com
Sun, 15 Dec 2002 15:17:08 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv15449/Zope/App/ComponentArchitecture
Modified Files:
meta.zcml metaConfigure.py
Log Message:
Utilities and adapters can now be named.
For example:
x = getAdapter(self, Ifoo, name="spam")
but unnamed adapters and utilities are still the norm and default.
=== Zope3/lib/python/Zope/App/ComponentArchitecture/meta.zcml 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/ComponentArchitecture/meta.zcml:1.1 Mon Jun 17 14:31:24 2002
+++ Zope3/lib/python/Zope/App/ComponentArchitecture/meta.zcml Sun Dec 15 15:16:37 2002
@@ -2,10 +2,13 @@
<directives namespace="http://namespaces.zope.org/zope">
- <directive name="adapter" attributes="factory provides for permission"
- handler="Zope.App.ComponentArchitecture.metaConfigure.adapter" />
+ <directive
+ name="adapter"
+ attributes="factory provides for permission name"
+ handler="Zope.App.ComponentArchitecture.metaConfigure.adapter"
+ />
- <directive name="utility" attributes="component provides permission"
+ <directive name="utility" attributes="component provides permission name"
handler="Zope.App.ComponentArchitecture.metaConfigure.utility" />
<directive name="factory" attributes="component id"
=== Zope3/lib/python/Zope/App/ComponentArchitecture/metaConfigure.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/ComponentArchitecture/metaConfigure.py:1.4 Mon Nov 25 10:23:20 2002
+++ Zope3/lib/python/Zope/App/ComponentArchitecture/metaConfigure.py Sun Dec 15 15:16:37 2002
@@ -52,7 +52,7 @@
method=getattr(getServiceManager(None), methodName)
method(*args, **kwargs)
-def adapter(_context, factory, provides, for_=None, permission=None):
+def adapter(_context, factory, provides, for_=None, permission=None, name=''):
if for_ is not None: for_ = _context.resolve(for_)
provides = _context.resolve(provides)
factory = map(_context.resolve, factory.split())
@@ -64,10 +64,10 @@
factory.append(lambda c: Proxy(c, checker))
actions=[
Action(
- discriminator = ('adapter', for_, provides),
+ discriminator = ('adapter', for_, provides, name),
callable = checkingHandler,
args = (permission, 'Adapters', 'provideAdapter',
- for_, provides, factory),
+ for_, provides, factory, name),
),
Action(
discriminator = None,
@@ -90,7 +90,8 @@
return actions
-def utility(_context, provides, component=None, factory=None, permission=None):
+def utility(_context, provides, component=None, factory=None,
+ permission=None, name=''):
provides = _context.resolve(provides)
if factory:
@@ -110,10 +111,10 @@
return [
Action(
- discriminator = ('utility', provides),
+ discriminator = ('utility', provides, name),
callable = checkingHandler,
args = (permission, 'Utilities', 'provideUtility',
- provides, component),
+ provides, component, name),
),
Action(
discriminator = None,