[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI - IGenericCreatorMarker.py:1.1.4.1 Addable.py:1.1.2.6 metaConfigure.py:1.1.2.10 zmi-meta.zcml:1.1.2.5 zmi.zcml:1.1.2.6

Gary Poster garyposter@earthlink.net
Wed, 3 Apr 2002 22:53:52 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	Addable.py metaConfigure.py zmi-meta.zcml zmi.zcml 
Added Files:
      Tag: Zope-3x-branch
	IGenericCreatorMarker.py 
Log Message:
checking in gary-pre_create_view-branch, with support for create namespace.  Because I merged in the Zope-3x-branch earlier and then had to run the license script again, many (most?) of the files were touched.  I am checking these in incrementally, since I ran into trouble overloading the cvs server when I had to do this for my own branch.  I will notate the last checkin, and then immediately check it out again to check my work.


=== Added File Zope3/lib/python/Zope/App/ZMI/IGenericCreatorMarker.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# 
##############################################################################
""" ZMI Generic Creator Marker Interface

$Id: IGenericCreatorMarker.py,v 1.1.4.1 2002/04/04 03:53:21 poster Exp $
"""


from Interface import Interface
class IGenericCreatorMarker(Interface):
    "This is the marker interface for the default create view"



=== Zope3/lib/python/Zope/App/ZMI/Addable.py 1.1.2.5 => 1.1.2.6 ===
 class Addables:
 
-    def provideAddable(self, id, title, description):
-        self.__reg.append(Addable(id, title, description))
+    def provideAddable(self, id, title, description, marker_interface=None):
+        self.__reg.append(Addable(id, title, description, marker_interface=marker_interface))
 
     def getAddables(self, ob):
         return self.__reg[:]
@@ -47,11 +47,16 @@
 
 class Addable:
 
-    def __init__(self, id, title, description, icon=None):
+    def __init__(self, id, title, description, icon=None, marker_interface=None):
         self.__id = id
         self.__title = title
         self.__description = description
         self.__icon = icon
+        if marker_interface:
+            if hasattr(self, "__implements__"): 
+                # not checking to see if already there...
+                self.__implements__ = marker_interface, self.__implements__
+            else: self.__implements__=marker_interface
 
     def id(self): return self.__id
     def title(self): return self.__title


=== Zope3/lib/python/Zope/App/ZMI/metaConfigure.py 1.1.2.9 => 1.1.2.10 ===
 from Zope.ComponentArchitecture import provideFactory
 import Addable
+from IGenericCreatorMarker import IGenericCreatorMarker
 
 class ClassFactory:
     __implements__ = IFactory
@@ -29,12 +30,12 @@
         self.__permission__ = permission
         self._class = _class
 
-    def __call__(self):
-        return self._class()
+    def __call__(self, *args, **kwargs):
+        return self._class(*args, **kwargs)
 
 
 def provideClass(registry, qualified_name, _class, permission,
-                 title, description=''):
+                 title, description='', marker_interface=None):
     """Provide simple class setup
 
     - create a component
@@ -47,7 +48,7 @@
     """
     factory = ClassFactory(_class, permission)
     provideFactory(qualified_name, factory)
-    registry.provideAddable(qualified_name, title, description)
+    registry.provideAddable(qualified_name, title, description, marker_interface)
 
 
 def ServiceClassDir(_context, name, class_, permission_id, title,
@@ -61,14 +62,16 @@
              )
         ]
 
-
 def ContentClassDir(_context, name, class_, permission_id, title,
-                    description=''):
+                    description='',
+		    marker_interface=IGenericCreatorMarker):
+    if marker_interface is not IGenericCreatorMarker:
+        marker_interface=_context.resolve(marker_interface)
     return [
         Action(
             discriminator = name,
             callable = provideClass,
             args = (Addable.ContentAddables, name, _context.resolve(class_),
-                    permission_id, title, description)
+                    permission_id, title, description, marker_interface)
             )
         ]


=== Zope3/lib/python/Zope/App/ZMI/zmi-meta.zcml 1.1.2.4 => 1.1.2.5 ===
 
     <directive name="factoryFromClass"
-               attributes="name, class, permission_id, title, description"
+               attributes="name, class, permission_id, title, description, marker_interface"
                handler="Zope.App.ZMI.metaConfigure.ContentClassDir" />
 
     <directive name="tabs" attributes="for"


=== Zope3/lib/python/Zope/App/ZMI/zmi.zcml 1.1.2.5 => 1.1.2.6 ===
                          methods="getZMIViews"/>
 
+  <security:protectClass 
+    name=".IGenericCreatorMarker."
+    interface=".IGenericCreatorMarker."
+    permission_id="Zope.ManageContent"  />
+    
+    <include package=".Views" file="views.zcml" />
 
 </zopeConfigure>