[Zope3-checkins] CVS: Zope3/src/zope/app/component - contentdirective.py:1.5 meta.zcml:1.9 metaconfigure.py:1.14 metadirectives.py:NONE

Anthony Baxter anthony@interlink.com.au
Sat, 2 Aug 2003 05:11:51 -0400


Update of /cvs-repository/Zope3/src/zope/app/component
In directory cvs.zope.org:/tmp/cvs-serv24272/zope/app/component

Modified Files:
	contentdirective.py meta.zcml metaconfigure.py 
Removed Files:
	metadirectives.py 
Log Message:
Backing out philiKON's changes - they broke the functional tests, and
from his signoff on IRC, I don't think he's going to be around until 
Monday. As I'm working on the Catalog functional tests, this is pretty
annoying. I tried to figure out how to just back out bits til I found the
broken stuff, but it's a pretty serious refactoring. I'll send a message
to zope3-checkins with the CVS commands used for this, so that someone
can undo the backout if they wish.


=== Zope3/src/zope/app/component/contentdirective.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/component/contentdirective.py:1.4	Sat Aug  2 03:04:01 2003
+++ Zope3/src/zope/app/component/contentdirective.py	Sat Aug  2 05:11:15 2003
@@ -21,7 +21,9 @@
 from zope.component import getService
 from zope.app.services.servicenames import Interfaces, Factories
 from zope.configuration.exceptions import ConfigurationError
+from zope.configuration.action import Action
 from zope.app.component.classfactory import ClassFactory
+from zope.app.component.metaconfigure import resolveInterface
 from zope.app.security.protectclass \
     import protectLikeUnto, protectName, protectSetAttribute
 from zope.app.security.registries.permissionregistry import permissionRegistry
@@ -48,7 +50,7 @@
 
     def __init__(self, _context, class_):
         self.__id = class_
-        self.__class = class_
+        self.__class = _context.resolve(class_)
         if isinstance(self.__class, ModuleType):
             raise ConfigurationError('Content class attribute must be a class')
         # not used yet
@@ -57,119 +59,137 @@
         self.__context = _context
 
     def implements(self, _context, interface):
-        for interface in interface:
-            _context.action(
-                discriminator = (
-                'ContentDirective', self.__class, object()),
-                callable = classImplements,
-                args = (self.__class, interface),
-                )
-            _context.action(
-                discriminator = None,
-                callable = handler,
-                args = (Interfaces, 'provideInterface',
-                        interface.__module__+
-                        '.'+
-                        interface.__name__,
-                        interface)
-                )
+        r = []
+        for interface in interface.strip().split():
+
+            resolved_interface = resolveInterface(_context, interface)
+            r += [
+                Action(
+                    discriminator = (
+                        'ContentDirective', self.__class, object()),
+                    callable = classImplements,
+                    args = (self.__class, resolved_interface),
+                    ),
+                Action(
+                   discriminator = None,
+                   callable = handler,
+                   args = (Interfaces, 'provideInterface',
+                           resolved_interface.__module__+
+                           '.'+
+                           resolved_interface.__name__,
+                           resolved_interface)
+                   )
+                ]
+        return r
 
     def require(self, _context,
                 permission=None, attributes=None, interface=None,
                 like_class=None, set_attributes=None, set_schema=None):
         """Require a the permission to access a specific aspect"""
+
         if like_class:
-            self.__mimic(_context, like_class)
+            r = self.__mimic(_context, like_class)
+        else:
+            r = []
 
         if not (interface or attributes or set_attributes or set_schema):
-            if like_class:
-                return
+            if r:
+                return r
             raise ConfigurationError("Nothing required")
 
         if not permission:
             raise ConfigurationError("No permission specified")
 
+
         if interface:
-            for i in interface:
-                if i:
-                    self.__protectByInterface(i, permission)
+            for i in interface.strip().split():
+                self.__protectByInterface(i, permission, r)
         if attributes:
-            self.__protectNames(attributes, permission)
+            self.__protectNames(attributes, permission, r)
         if set_attributes:
-            self.__protectSetAttributes(set_attributes, permission)
+            self.__protectSetAttributes(set_attributes, permission, r)
         if set_schema:
-            for s in set_schema:
-                self.__protectSetSchema(s, permission)
+            for s in set_schema.strip().split():
+                self.__protectSetSchema(s, permission, r)
+
+
+        return r
 
     def __mimic(self, _context, class_):
         """Base security requirements on those of the given class"""
-        _context.action(
-            discriminator=('mimic', self.__class, object()),
-            callable=protectLikeUnto,
-            args=(self.__class, class_),
-            )
+        class_to_mimic = _context.resolve(class_)
+        return [
+            Action(discriminator=('mimic', self.__class, object()),
+                   callable=protectLikeUnto,
+                   args=(self.__class, class_to_mimic),
+                   )
+            ]
 
     def allow(self, _context, attributes=None, interface=None):
         """Like require, but with permission_id zope.Public"""
         return self.require(_context, PublicPermission, attributes, interface)
 
-    def __protectByInterface(self, interface, permission_id):
+
+
+    def __protectByInterface(self, interface, permission_id, r):
         "Set a permission on names in an interface."
+        interface = resolveInterface(self.__context, interface)
         for n, d in interface.namesAndDescriptions(1):
-            self.__protectName(n, permission_id)
-        self.__context.action(
-            discriminator = None,
-            callable = handler,
-            args = (Interfaces, 'provideInterface',
-                    interface.__module__+ '.'+ interface.__name__,
-                    interface)
+            self.__protectName(n, permission_id, r)
+        r.append(
+            Action(
+               discriminator = None,
+               callable = handler,
+               args = (Interfaces, 'provideInterface',
+                       interface.__module__+ '.'+ interface.__name__,
+                       interface)
+               )
             )
 
-    def __protectName(self, name, permission_id):
+    def __protectName(self, name, permission_id, r):
         "Set a permission on a particular name."
-        self.__context.action(
-            discriminator = ('protectName', self.__class, name),
-            callable = protectName,
-            args = (self.__class, name, permission_id)
-            )
+        r.append((
+            ('protectName', self.__class, name),
+            protectName, (self.__class, name, permission_id)))
 
-    def __protectNames(self, names, permission_id):
+    def __protectNames(self, names, permission_id, r):
         "Set a permission on a bunch of names."
-        for name in names:
-            self.__protectName(name, permission_id)
+        for name in names.split():
+            self.__protectName(name.strip(), permission_id, r)
 
-    def __protectSetAttributes(self, names, permission_id):
+    def __protectSetAttributes(self, names, permission_id, r):
         "Set a permission on a bunch of names."
-        for name in names:
-            self.__context.action(
-                discriminator = ('protectSetAttribute', self.__class, name),
-                callable = protectSetAttribute,
-                args = (self.__class, name, permission_id)
-                )
+        for name in names.split():
+            r.append((
+                ('protectSetAttribute', self.__class, name),
+                protectSetAttribute, (self.__class, name, permission_id)))
 
-    def __protectSetSchema(self, schema, permission_id):
+    def __protectSetSchema(self, schema, permission_id, r):
         "Set a permission on a bunch of names."
-        _context = self.__context
+        schema = resolveInterface(self.__context, schema)
         for name in schema:
             field = schema[name]
             if IField.isImplementedBy(field) and not field.readonly:
-                _context.action(
-                    discriminator = ('protectSetAttribute', self.__class, name),
-                    callable = protectSetAttribute,
-                    args = (self.__class, name, permission_id)
-                    )
-        _context.action(
-            discriminator = None,
-            callable = handler,
-            args = (Interfaces, 'provideInterface',
-                    schema.__module__+ '.'+ schema.__name__,
-                    schema)
+                r.append((
+                    ('protectSetAttribute', self.__class, name),
+                    protectSetAttribute, (self.__class, name, permission_id)))
+
+        r.append(
+            Action(
+               discriminator = None,
+               callable = handler,
+               args = (Interfaces, 'provideInterface',
+                       schema.__module__+ '.'+ schema.__name__,
+                       schema)
+               )
             )
 
+
     def __call__(self):
         "Handle empty/simple declaration."
         return ()
 
+
     def factory(self, _context,
                 permission=None, title="", id=None, description=''):
         """Register a zmi factory for this class"""
@@ -179,12 +199,14 @@
         # note factories are all in one pile, services and content,
         # so addable names must also act as if they were all in the
         # same namespace, despite the service/content division
-        _context.action(
-            discriminator = ('FactoryFromClass', id),
-            callable = provideClass,
-            args = (id, self.__class,
-                    permission, title, description)
-            )
+        return [
+            Action(
+                discriminator = ('FactoryFromClass', id),
+                callable = provideClass,
+                args = (id, self.__class,
+                        permission, title, description)
+                )
+            ]
 
 def provideClass(id, _class, permission=None,
                  title='', description=''):


=== Zope3/src/zope/app/component/meta.zcml 1.8 => 1.9 ===
--- Zope3/src/zope/app/component/meta.zcml:1.8	Sat Aug  2 03:04:01 2003
+++ Zope3/src/zope/app/component/meta.zcml	Sat Aug  2 05:11:15 2003
@@ -1,125 +1,261 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
-
-  <meta:directives namespace="http://namespaces.zope.org/zope">
-
-    <meta:directive
-        name="interface"
-        schema=".metadirectives.IInterfaceDirective"
-        handler="zope.app.component.metaconfigure.interface"
-        />
-
-    <meta:directive
-        name="adapter"
-        schema=".metadirectives.IAdapterDirective"
-        handler="zope.app.component.metaconfigure.adapter"
-        />
-
-    <meta:directive
-        name="utility"
-        schema=".metadirectives.IUtilityDirective"
-        handler="zope.app.component.metaconfigure.utility"
-        />
-
-    <meta:directive
-        name="factory"
-        schema=".metadirectives.IFactoryDirective"
-        handler="zope.app.component.metaconfigure.factory"
-        />
-
-    <meta:directive
-        name="view"
-        schema=".metadirectives.IViewDirective"
-        handler="zope.app.component.metaconfigure.view"
-        />
-
-    <meta:directive
-        name="defaultView"
-        schema=".metadirectives.IViewDirective"
-        handler="zope.app.component.metaconfigure.defaultView"
-        />
-
-    <meta:directive
-        name="resource"
-        schema=".metadirectives.IResourceDirective"
-        handler="zope.app.component.metaconfigure.resource"
-        />
-
-    <meta:directive
-        name="skin"
-        schema=".metadirectives.ISkinDirective"
-        handler="zope.app.component.metaconfigure.skin"
-        />
-
-    <meta:directive
-        name="serviceType"
-        schema=".metadirectives.IServiceTypeDirective"
-        handler="zope.app.component.metaconfigure.serviceType"
-        />
-
-    <meta:directive
-        name="service" 
-        schema=".metadirectives.IServiceDirective"
-        handler="zope.app.component.metaconfigure.service"
-        />
+<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
 
-    <meta:complexDirective
-        name="class"
-        schema=".metadirectives.IClassDirective"
-        handler="zope.app.component.contentdirective.ContentDirective"
-        >
+  <directives namespace="http://namespaces.zope.org/zope">
 
-      <meta:subdirective
-          name="implements"
-          schema=".metadirectives.IImplementsSubdirective"
-          />
+    <directive name="interface" attributes="interface"
+       handler="zope.app.component.metaconfigure.interface" />
 
-      <meta:subdirective
-          name="require"
-          schema=".metadirectives.IRequireSubdirective"
-          />
+    <directive name="adapter" 
+               attributes="factory provides for permission name"
+       handler="zope.app.component.metaconfigure.adapter" />
 
-      <meta:subdirective
-          name="allow"
-          schema=".metadirectives.IAllowSubdirective"
-          />
+    <directive name="utility" 
+               attributes="component provides permission name factory"
+       handler="zope.app.component.metaconfigure.utility" />
 
-      <meta:subdirective
-          name="factory"
-          schema=".metadirectives.IFactorySubdirective"
-          />
+    <directive name="factory" attributes="component id permission"
+       handler="zope.app.component.metaconfigure.factory" />
+
+    <directive
+       name="view"
+       attributes="component type name for layer factory
+                   permission allowed_interface allowed_attributes"
+       handler="zope.app.component.metaconfigure.view" />
+
+    <directive name="defaultView"
+               attributes="component type name for layer factory
+                           permission allowed_attributes"
+       handler="zope.app.component.metaconfigure.defaultView" />
+
+    <directive
+       name="resource"
+       attributes="component type name layer factory
+                   permission allowed_interface allowed_attributes"
+       handler="zope.app.component.metaconfigure.resource" />
+
+    <directive name="skin" attributes="name type layers"
+        handler="zope.app.component.metaconfigure.skin" />
 
-    </meta:complexDirective>
+    <directive name="serviceType" attributes="id interface"
+       handler="zope.app.component.metaconfigure.serviceType" />
 
-    <meta:complexDirective
+    <directive name="service" 
+               attributes="serviceType component permission factory"
+       handler="zope.app.component.metaconfigure.service" />
+
+    <directive
         name="content"
-        schema=".metadirectives.IClassDirective"
         handler="zope.app.component.contentdirective.ContentDirective"
+        description="Make a component available as a content object type"
         >
-
-      <meta:subdirective
-          name="implements"
-          schema=".metadirectives.IImplementsSubdirective"
+      <attribute
+          name="class"
+          required="yes"
+          description="resolvable name of a class"
           />
 
-      <meta:subdirective
-          name="require"
-          schema=".metadirectives.IRequireSubdirective"
-          />
+      <subdirective name="implements">
 
-      <meta:subdirective
-          name="allow"
-          schema=".metadirectives.IAllowSubdirective"
-          />
+        <description>
+              Declare that the class given by the content
+              directive's class attribute implements a given interface
+          </description>
+
+        <attribute
+            name="interface"
+            required="yes"
+            description="resolvable name of an Interface"
+            />
+      </subdirective>
+
+      <subdirective name="require">
+        <description>
+            Indicate that the a specified list of names or the
+            names in a given Interface require a given permission for
+            access.
+          </description>
+
+        <attribute
+            name="permission"
+            required="no"
+            description="a permission id"
+            />
+
+        <attribute
+            name="attributes"
+            description="space-separated list of attribute names"
+            />
+
+        <attribute
+            name="set_attributes"
+            description="space-separated list of attribute names
+                         for attributes that can be set"
+            />
+
+        <attribute
+            name="set_schema"
+            >
+            Dotted name of a schema
+
+            The non-read-only fields in the schema can be set with the
+            specified permission.
+            
+          </attribute>
+
+        <attribute
+            name="interface"
+            description="the resolvable name of an interface"
+            />
+
+        <attribute name="like_class">
+          <description>
+                a class on which the security requirements
+                for this class will be based
+              </description>
+          </attribute>
+
+      </subdirective>
+
+      <subdirective name="allow">
+        <description>
+              Declare a part of the class to be publicly
+              viewable (that is, requires the zope.Public
+              permission).  Only one of the following two
+              attributes may be used.
+           </description>
+
+        <attribute
+            name="attributes"
+            description="space-separated list of attribute names"
+            />
+
+        <attribute
+            name="interface"
+            description="the resolvable name of an interface"
+            />
+
+      </subdirective>
+
+      <subdirective name="factory">
+
+        <description>
+              Specify the factory used to create this
+              content object
+          </description>
+
+        <attribute name="permission">
+          <description>
+                permission id required to use this factory.
+                Although optional, this attribute should normally
+                be specified.
+                </description>
+          </attribute>
+
+        <attribute name="id">
+          <description>
+                the identifier for this factory in the
+                ZMI factory identification scheme.  If not given, defaults
+                to the literal string given as the content directive's
+                'class' attribute.
+              </description>
+          </attribute>
+
+        <attribute name="title">
+          <description>
+                text suitable for use in the 'add content' menu of
+                a management interface
+              </description>
+          </attribute>
+
+        <attribute name="description">
+          <description>
+                longer narrative description of what this
+                factory does
+            </description>
+          </attribute>
+
+      </subdirective>
+    </directive>
 
-      <meta:subdirective
-          name="factory"
-          schema=".metadirectives.IFactorySubdirective"
+    <directive
+        name="class"
+        handler="zope.app.component.contentdirective.ContentDirective"
+        description="Make statements about a class"
+        >
+      <attribute
+          name="class"
+          required="yes"
+          description="resolvable name of a class"
           />
 
-    </meta:complexDirective>
+      <subdirective name="implements">
+
+        <description>
+              Declare that the class given by the content
+              directive's class attribute implements a given interface
+          </description>
+
+        <attribute
+            name="interface"
+            required="yes"
+            description="resolvable name of an Interface"
+            />
+      </subdirective>
+
+      <subdirective name="require">
+        <description>
+            Indicate that the a specified list of names or the
+            names in a given Interface require a given permission for
+            access.
+          </description>
+
+        <attribute
+            name="permission"
+            required="yes"
+            description="a permission id"
+            />
+
+        <attribute
+            name="attributes"
+            description="space-separated list of attribute names"
+            />
+
+        <attribute
+            name="interface"
+            description="the resolvable name of an interface"
+            />
+
+        <attribute name="like_class">
+          <description>
+                a class on which the security requirements
+                for this class will be based
+              </description>
+          </attribute>
+
+      </subdirective>
+
+      <subdirective name="allow">
+        <description>
+              Declare a part of the class to be publicly
+              viewable (that is, requires the zope.Public
+              permission).  Only one of the following two
+              attributes may be used.
+           </description>
+
+        <attribute
+            name="attributes"
+            description="space-separated list of attribute names"
+            />
+
+        <attribute
+            name="interface"
+            description="the resolvable name of an interface"
+            />
+
+      </subdirective>
+
+    </directive>
 
-  </meta:directives>
+  </directives>
 
-</configure>
+</zopeConfigure>


=== Zope3/src/zope/app/component/metaconfigure.py 1.13 => 1.14 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.13	Sat Aug  2 03:04:01 2003
+++ Zope3/src/zope/app/component/metaconfigure.py	Sat Aug  2 05:11:15 2003
@@ -11,9 +11,6 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
-$Id$
-"""
 
 from zope.configuration.exceptions import ConfigurationError
 from zope.security.proxy import Proxy, ProxyFactory
@@ -21,6 +18,7 @@
 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.action import Action
 from zope.security.checker import InterfaceChecker, CheckerPublic, \
      Checker, NamesChecker
 from zope.app.security.registries.permissionregistry import permissionRegistry
@@ -57,42 +55,71 @@
     method(*args, **kwargs)
 
 def interface(_context, interface):
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface', '', interface)
-        )
+    interface = resolveInterface(_context, interface)
+    return [
+        Action(
+          discriminator = None,
+          callable = handler,
+          args = (Interfaces, 'provideInterface', '', interface)
+        ),
+      ]
+
 
 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_ = resolveInterface(_context, for_)
+
+    provides = resolveInterface(_context, provides)
+    factory = map(_context.resolve, factory.split())
+
     if permission is not None:
         if permission == PublicPermission:
             permission = CheckerPublic
         checker = InterfaceChecker(provides, permission)
         factory.append(lambda c: Proxy(c, checker))
-    _context.action(
-        discriminator = ('adapter', for_, provides, name),
-        callable = checkingHandler,
-        args = (permission, Adapters, 'provideAdapter',
-                for_, provides, factory, name),
-        )
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface', '', provides)
-        )
+    actions=[
+        Action(
+            discriminator = ('adapter', for_, provides, name),
+            callable = checkingHandler,
+            args = (permission, Adapters, 'provideAdapter',
+                    for_, provides, factory, name),
+               ),
+        Action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface', '', provides)
+              )
+              ]
     if for_ is not None:
-        _context.action(
+        actions.append
+        (
+        Action(
             discriminator = None,
             callable = handler,
             args = (Interfaces, 'provideInterface', '', for_)
-            )
+              )
+         )
+
+    return actions
+
 
 def utility(_context, provides, component=None, factory=None,
             permission=None, name=''):
+    provides = resolveInterface(_context, provides)
+
     if factory:
         if component:
             raise TypeError("Can't specify factory and component.")
-        component = factory()
+
+        component = _context.resolve(factory)()
+    else:
+        component = _context.resolve(component)
 
     if permission is not None:
         if permission == PublicPermission:
@@ -101,25 +128,35 @@
 
         component = Proxy(component, checker)
 
-    _context.action(
-        discriminator = ('utility', provides, name),
-        callable = checkingHandler,
-        args = (permission, 'Utilities', 'provideUtility',
-                provides, component, name),
-        )
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface',
-                provides.__module__+'.'+provides.__name__, provides)
-        )
+    return [
+        Action(
+            discriminator = ('utility', provides, name),
+            callable = checkingHandler,
+            args = (permission, 'Utilities', 'provideUtility',
+                    provides, component, name),
+            ),
+        Action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    provides.__module__+'.'+provides.__name__, provides)
+              )
+        ]
+
 
 def factory(_context, component, id=None, permission=None):
-    _context.action(
-        discriminator = ('factory', id),
-        callable = provideFactory,
-        args = (id, component, permission),
-        )
+    if id is None:
+        id = component
+
+    component = _context.resolve(component)
+
+    return [
+        Action(
+            discriminator = ('factory', id),
+            callable = provideFactory,
+            args = (id, component, permission),
+            )
+        ]
 
 def provideFactory(name, factory, permission):
     # make sure the permission is defined
@@ -131,13 +168,13 @@
 
     if permission:
         # XXX should getInterfaces be public, as below?
-        factory = ProxyFactory(
-            factory,
-            NamesChecker(('getInterfaces',),
-                         __call__=permission)
-            )
+        factory = ProxyFactory(factory,
+                               NamesChecker(('getInterfaces',),
+                                            __call__=permission))
+
     getService(None, Factories).provideFactory(name, factory)
 
+
 def _checker(_context, permission, allowed_interface, allowed_attributes):
     if (not allowed_attributes) and (not allowed_interface):
         allowed_attributes = "__call__"
@@ -146,15 +183,14 @@
         permission = CheckerPublic
 
     require={}
-    if allowed_attributes:
-        for name in allowed_attributes:
-            require[name] = permission
+    for name in (allowed_attributes or '').split():
+        require[name] = permission
     if allowed_interface:
-        for i in allowed_interface:
-            for name in i.names(all=True):
-                require[name] = permission
+        for name in resolveInterface(_context, allowed_interface).names(all=True):
+            require[name] = permission
 
     checker = Checker(require.get)
+
     return checker
 
 def resource(_context, factory, type, name, layer='default',
@@ -168,6 +204,11 @@
             "allowed_attributes"
             )
 
+
+    type = _context.resolve(type)
+    factory = _context.resolve(factory)
+
+
     if permission:
 
         checker = _checker(_context, permission,
@@ -178,18 +219,20 @@
 
         factory = proxyResource
 
-    _context.action(
-        discriminator = ('resource', name, type, layer),
-        callable = checkingHandler,
-        args = (permission, Resources,'provideResource',
-                name, type, factory, layer),
-        )
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface',
-                type.__module__+'.'+type.__name__, type)
-        )
+    return [
+        Action(
+            discriminator = ('resource', name, type, layer),
+            callable = checkingHandler,
+            args = (permission, Resources,'provideResource',
+                    name, type, factory, layer),
+            ),
+        Action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    type.__module__+'.'+type.__name__, type)
+              )
+        ]
 
 def view(_context, factory, type, name, for_, layer='default',
          permission=None, allowed_interface=None, allowed_attributes=None):
@@ -204,6 +247,11 @@
             "allowed_attributes"
             )
 
+    if for_ is not None:
+        for_ = resolveInterface(_context, for_)
+    type = _context.resolve(type)
+
+    factory = map(_context.resolve, factory.strip().split())
     if not factory:
         raise ConfigurationError("No view factory specified.")
 
@@ -217,27 +265,33 @@
 
         factory[-1] = proxyView
 
-    _context.action(
-        discriminator = ('view', for_, name, type, layer),
-        callable = checkingHandler,
-        args = (permission, Views,'provideView', for_, name,
-                type, factory, layer),
-        )
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface',
-                type.__module__+'.'+type.__name__, type)
-        )
-
+    actions=[
+        Action(
+            discriminator = ('view', for_, name, type, layer),
+            callable = checkingHandler,
+            args = (permission, Views,'provideView', for_, name,
+                    type, factory, layer),
+            ),
+        Action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    type.__module__+'.'+type.__name__, type)
+            )
+            ]
     if for_ is not None:
-        _context.action(
+        actions.append
+        (
+        Action(
             discriminator = None,
             callable = handler,
             args = (Interfaces, 'provideInterface',
                     for_.__module__+'.'+for_.__name__,
                     for_)
-            )
+              )
+         )
+
+    return actions
 
 def defaultView(_context, type, name, for_, **__kw):
 
@@ -245,40 +299,55 @@
         for_ = None
 
     if __kw:
-        view(_context, type=type, name=name, for_=for_, **__kw)
+        actions = view(_context, type=type, name=name, for_=for_, **__kw)
+    else:
+        actions = []
+
+    if for_ is not None:
+        for_ = resolveInterface(_context, for_)
+    type = _context.resolve(type)
 
-    _context.action(
+    actions += [
+        Action(
         discriminator = ('defaultViewName', for_, type, name),
         callable = handler,
         args = (Views,'setDefaultViewName', for_, type, name),
-        )
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface',
-                type.__module__+'.'+type.__name__, type)
-        )
-
+        ),
+        Action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    type.__module__+'.'+type.__name__, type)
+            )
+               ]
     if for_ is not None:
-        _context.action(
+        actions.append
+        (
+        Action(
             discriminator = None,
             callable = handler,
             args = (Interfaces, 'provideInterface',
                     for_.__module__+'.'+for_.__name__, for_)
-            )
+              )
+         )
+
+    return actions
 
 def serviceType(_context, id, interface):
-    _context.action(
-        discriminator = ('serviceType', id),
-        callable = managerHandler,
-        args = ('defineService', id, interface),
-        )
-    _context.action(
-        discriminator = None,
-        callable = provideInterface,
-        args = (interface.__module__+'.'+interface.__name__,
-                interface)
-        )
+    interface = resolveInterface(_context, interface)
+    return [
+        Action(
+            discriminator = ('serviceType', id),
+            callable = managerHandler,
+            args = ('defineService', id, interface),
+            ),
+        Action(
+            discriminator = None,
+            callable = provideInterface,
+            args = (interface.__module__+'.'+interface.__name__,
+                    interface)
+            )
+        ]
 
 def provideService(serviceType, component, permission):
     # This is needed so we can add a security proxy.
@@ -288,6 +357,7 @@
     service_manager = getServiceManager(None)
 
     if permission:
+
         for stype, interface in service_manager.getServiceDefinitions():
             if stype == serviceType:
                 break
@@ -312,33 +382,39 @@
         if component:
             raise TypeError("Can't specify factory and component.")
 
-        component = factory()
-
-    _context.action(
-        discriminator = ('service', serviceType),
-        callable = provideService,
-        args = (serviceType, component, permission),
-        )
+        component = _context.resolve(factory)()
+    else:
+        component = _context.resolve(component)
+
+    return [
+        Action(
+            discriminator = ('service', serviceType),
+            callable = provideService,
+            args = (serviceType, component, permission),
+            )
+        ]
 
 def skin(_context, name, layers, type):
+    type = _context.resolve(type)
     if ',' in layers:
         raise TypeError("Commas are not allowed in layer names.")
 
-    _context.action(
-        discriminator = ('skin', name, type),
-        callable = handler,
-        args = (Skins,'defineSkin',name, type, layers)
-        )
-
-    _context.action(
-        discriminator = None,
-        callable = handler,
-        args = (Interfaces, 'provideInterface',
-                type.__module__+'.'+type.__name__, type)
-        )
+    layers = layers.strip().split()
+    actions = [
+        Action(
+            discriminator = ('skin', name, type),
+            callable = handler,
+            args = (Skins,'defineSkin',name, type, layers)
+              ),
+        Action(
+            discriminator = None,
+            callable = handler,
+            args = (Interfaces, 'provideInterface',
+                    type.__module__+'.'+type.__name__, type)
+              )
+             ]
+    return actions
 
-# XXX this will have to incorporated into
-# zope.configuration.fields.GlobalObject
 def resolveInterface(_context, id):
     interface = interfaceService.queryInterface(id, None)
     if interface is None:

=== Removed File Zope3/src/zope/app/component/metadirectives.py ===