[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ContentDirective - ContentDirective.py:1.6

Jim Fulton jim@zope.com
Thu, 11 Jul 2002 14:21:59 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ContentDirective
In directory cvs.zope.org:/tmp/cvs-serv7355/lib/python/Zope/App/ContentDirective

Modified Files:
	ContentDirective.py 
Log Message:

Reimplemented service managers to be package based. Service managers
are no longer containers. They have a packages subobject (not a
packages service) that contains packages. TTW components are created
in packages. To register a component, create the appropriate component
directive objects (these should be called configuration objects).

This should be viewed as a prototype to illustrate the idea of
packages. Lots of things can change (especially UI) and many things
aren't done (e.g. visiting created directives).

In the course of this, I fixed a bunch of bugs and problems in
traversal machinery. 

I also renamed Zope.ComponentArchitecture.IServiceManager back to
IServiceService, since this interface doesn't actually specify any
management.  



=== Zope3/lib/python/Zope/App/ContentDirective/ContentDirective.py 1.5 => 1.6 ===
 
 $Id$
 """
+from types import ModuleType
+from Interface.Implements import implements
 from Zope.Configuration.ConfigurationDirectiveInterfaces \
      import INonEmptyDirective
 from Zope.ComponentArchitecture import getService
 from Zope.Configuration.Exceptions import ConfigurationError
 from Zope.Configuration.Action import Action
-import Interface
 from Zope.App.ComponentArchitecture.ClassFactory import ClassFactory
 from Zope.App.Security.protectClass \
     import protectLikeUnto, protectName, checkPermission
@@ -38,8 +39,10 @@
     __implements__ = INonEmptyDirective
 
     def __init__(self, _context, class_):
-        self.__id = class_
+        self.__id = class_        
         self.__class = _context.resolve(class_)
+        if isinstance(self.__class, ModuleType):
+            raise ConfigurationError('Content class attribute must be a class')
         # not used yet
         #self.__name = class_
         #self.__normalized_name = _context.getNormalizedName(class_)
@@ -50,7 +53,7 @@
         return [
             Action(
                 discriminator = ('ContentDirective', self.__class, object()),
-                callable = Interface.Implements.implements,
+                callable = implements,
                 # the last argument is check=1, which causes implements
                 # to verify that the class does implement the interface
                 args = (self.__class, resolved_interface, 1),