[Zope3-checkins] CVS: Zope3/src/zope/app/component - metaconfigure.py:1.5
Jim Fulton
jim@zope.com
Mon, 3 Feb 2003 13:09:21 -0500
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv7871/src/zope/app/component
Modified Files:
metaconfigure.py
Log Message:
Changed the adapter directive to require a for attribute.
Use * to register for all objects.
=== Zope3/src/zope/app/component/metaconfigure.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.4 Sat Jan 25 00:13:41 2003
+++ Zope3/src/zope/app/component/metaconfigure.py Mon Feb 3 13:08:48 2003
@@ -63,8 +63,16 @@
]
-def adapter(_context, factory, provides, for_=None, permission=None, name=''):
- if for_ is not None: for_ = _context.resolve(for_)
+def adapter(_context, factory, provides, for_, permission=None, name=''):
+ if for_ == '*':
+ for_ = None
+ elif not for_:
+ raise ValueError(
+ "A for interface must be provided. Use * for all objects.")
+
+ if for_:
+ for_ = _context.resolve(for_)
+
provides = _context.resolve(provides)
factory = map(_context.resolve, factory.split())