[Zope3-checkins] CVS: Zope3/src/zope/app/component - contentdirective.py:1.17 metaconfigure.py:1.29 metadirectives.py:1.13

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Mar 9 07:39:56 EST 2004


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

Modified Files:
	contentdirective.py metaconfigure.py metadirectives.py 
Log Message:


Removed the permission attribute from the two factoy directives. All factories
are public now. This was discussed recently on the mailing list and Jim okayed
it.




=== Zope3/src/zope/app/component/contentdirective.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/component/contentdirective.py:1.16	Mon Mar  8 07:05:54 2004
+++ Zope3/src/zope/app/component/contentdirective.py	Tue Mar  9 07:39:25 2004
@@ -17,18 +17,15 @@
 """
 from types import ModuleType
 from zope.interface import classImplements
-from zope.component.factory import FactoryInfo
-from zope.app.services.servicenames import Factories
+from zope.schema.interfaces import IField
 from zope.configuration.exceptions import ConfigurationError
-from zope.app.component.classfactory import ClassFactory
+
+from zope.app import zapi
+from zope.component.factory import Factory
 from zope.app.security.protectclass \
     import protectLikeUnto, protectName, protectSetAttribute
 from zope.app.component.interface import provideInterface
-from zope.app import zapi
-from zope.security.checker import CheckerPublic
-from zope.app.security.permission import checkPermission 
-
-from zope.schema.interfaces import IField
+from metaconfigure import factory
 
 PublicPermission = 'zope.Public'
 
@@ -45,11 +42,6 @@
     method=getattr(zapi.getService(None, serviceName), methodName)
     method(*args, **kwargs)
 
-def assertPermission(permission=None, *args, **kw):
-    """Check if permission is defined"""
-    if permission is not None:
-        checkPermission(None, permission)
-
 class ContentDirective:
 
     def __init__(self, _context, class_):
@@ -171,37 +163,13 @@
         "Handle empty/simple declaration."
         return ()
 
-    def factory(self, _context,
-                permission=None, title="", id=None, description=''):
+    def factory(self, _context, id=None, title="", description=''):
         """Register a zmi factory for this class"""
 
         id = id or self.__id
+        factoryObj = Factory(self.__class, title, description)
 
         # 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)
-            )
-
-def provideClass(id, _class, permission=None,
-                 title='', description=''):
-    """Provide simple class setup
-
-    - create a component
-
-    - set component permission
-    """
-
-    assertPermission(permission)
-
-    if permission == PublicPermission:
-        permission = CheckerPublic
-
-    factory = ClassFactory(_class, title, description, permission)
-    info = FactoryInfo(title, description)
-
-    zapi.getService(None, Factories).provideFactory(id, factory, info)
+        factory(_context, factoryObj, id, title, description)


=== Zope3/src/zope/app/component/metaconfigure.py 1.28 => 1.29 ===
--- Zope3/src/zope/app/component/metaconfigure.py:1.28	Mon Mar  8 07:05:54 2004
+++ Zope3/src/zope/app/component/metaconfigure.py	Tue Mar  9 07:39:25 2004
@@ -21,12 +21,12 @@
 from zope.security.checker import InterfaceChecker, CheckerPublic, \
      Checker, NamesChecker
 from zope.security.proxy import Proxy, ProxyFactory
-from zope.component.factory import FactoryInfo
+from zope.component.interfaces import IFactory
 
 from zope.app import zapi
 from zope.app.component.interface import queryInterface
 from zope.app.security.permission import checkPermission 
-from zope.app.services.servicenames import Adapters, Factories, Presentation
+from zope.app.services.servicenames import Adapters, Presentation
 
 
 PublicPermission = 'zope.Public'
@@ -133,31 +133,15 @@
         args = (provides.__module__ + '.' + provides.getName(), provides)
                )
 
-def factory(_context, component, id=None, title=None, description=None, 
-            permission=None):
-    _context.action(
-        discriminator = ('factory', id),
-        callable = provideFactory,
-        args = (id, component, title, description, permission),
-        )
-
-def provideFactory(name, factory, title, description, permission):
-    # make sure the permission is defined
-    if permission is not None:
-        checkPermission(None, permission)
+def factory(_context, component, id, title=None, description=None):
+    if title is not None:
+        component.title = title
+        
+    if description is not None:
+        component.description = description
 
-    if permission == PublicPermission:
-        permission = CheckerPublic
+    utility(_context, IFactory, component, permission=PublicPermission, name=id)
 
-    if permission:
-        # XXX should getInterfaces be public, as below?
-        factory = ProxyFactory(
-            factory,
-            NamesChecker(('getInterfaces',),
-                         __call__=permission)
-            )
-    info = FactoryInfo(title, description)
-    zapi.getService(None, Factories).provideFactory(name, factory, info)
 
 def _checker(_context, permission, allowed_interface, allowed_attributes):
     if (not allowed_attributes) and (not allowed_interface):


=== Zope3/src/zope/app/component/metadirectives.py 1.12 => 1.13 ===
--- Zope3/src/zope/app/component/metadirectives.py:1.12	Tue Mar  2 09:25:49 2004
+++ Zope3/src/zope/app/component/metadirectives.py	Tue Mar  9 07:39:25 2004
@@ -222,10 +222,6 @@
         required=False
         )
 
-    permission = Id(
-        title=u"Permission",
-        required=False
-        )
 
 class IViewDirective(IBasicViewInformation, IBasicResourceInformation):
     """
@@ -429,14 +425,6 @@
         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.""",
-        required=False
-        )
-
-    permission = Id(
-        title=u"Permission",
-        description=u"""
-        permission id required to use this factory.  Although
-        optional, this attribute should normally be specified.""",
         required=False
         )
 




More information about the Zope3-Checkins mailing list