[Zope3-checkins] CVS: Zope3/src/zope/app/component - metaconfigure.py:1.9
Philipp von Weitershausen
philikon@philikon.de
Wed, 9 Apr 2003 16:52:01 -0400
Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv3948/component
Modified Files:
metaconfigure.py
Log Message:
* introduced IXMLRepresentable interface for objects representing xml.
* introduced a new ZCML directive to register XML Schemas as interfaces
by specifying their URI.
* changed the way interfaces are resolved in all configuration directives
and some other places. Thus, you can now also specify the URI of an
XML schema instead of a dotted interface name everywhere you are required
to specify an interface name.
=== Zope3/src/zope/app/component/metaconfigure.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.8 Tue Feb 11 21:17:16 2003
+++ Zope3/src/zope/app/component/metaconfigure.py Wed Apr 9 16:51:30 2003
@@ -17,6 +17,7 @@
from zope.component import getService, getServiceManager
from zope.app.services.servicenames import Adapters, Interfaces, Skins
from zope.app.services.servicenames import Views, Resources, Factories
+from zope.app.component.globalinterfaceservice import interfaceService
from zope.configuration import namespace
from zope.interface import Interface
from zope.configuration.action import Action
@@ -55,7 +56,7 @@
method(*args, **kwargs)
def interface(_context, interface):
- interface = _context.resolve(interface)
+ interface = resolveInterface(_context, interface)
return [
Action(
discriminator = None,
@@ -73,9 +74,9 @@
"A for interface must be provided. Use * for all objects.")
if for_:
- for_ = _context.resolve(for_)
+ for_ = resolveInterface(_context, for_)
- provides = _context.resolve(provides)
+ provides = resolveInterface(_context, provides)
factory = map(_context.resolve, factory.split())
if permission is not None:
@@ -111,7 +112,7 @@
def utility(_context, provides, component=None, factory=None,
permission=None, name=''):
- provides = _context.resolve(provides)
+ provides = resolveInterface(_context, provides)
if factory:
if component:
@@ -169,7 +170,7 @@
for name in (allowed_attributes or '').split():
require[name] = permission
if allowed_interface:
- for name in _context.resolve(allowed_interface).names(all=True):
+ for name in resolveInterface(_context, allowed_interface).names(all=True):
require[name] = permission
checker = Checker(require.get)
@@ -230,7 +231,8 @@
"allowed_attributes"
)
- if for_ is not None: for_ = _context.resolve(for_)
+ if for_ is not None:
+ for_ = resolveInterface(_context, for_)
type = _context.resolve(type)
factory = map(_context.resolve, factory.strip().split())
@@ -286,7 +288,7 @@
actions = []
if for_ is not None:
- for_ = _context.resolve(for_)
+ for_ = resolveInterface(_context, for_)
type = _context.resolve(type)
actions += [
@@ -316,7 +318,7 @@
return actions
def serviceType(_context, id, interface):
- interface = _context.resolve(interface)
+ interface = resolveInterface(_context, interface)
return [
Action(
discriminator = ('serviceType', id),
@@ -396,3 +398,9 @@
)
]
return actions
+
+def resolveInterface(_context, id):
+ interface = interfaceService.queryInterface(id, None)
+ if interface is None:
+ interface = _context.resolve(id)
+ return interface