[Zope-Checkins] SVN: Zope/trunk/lib/python/App/ProductContext.py - registerClass now also adds z3 interfaces to 'interfaces' of the meta_type info

Yvo Schubbe y.2005- at wcm-solutions.de
Mon Oct 31 16:23:13 EST 2005


Log message for revision 39793:
  - registerClass now also adds z3 interfaces to 'interfaces' of the meta_type info
  - added some comments describing the meta_type info

Changed:
  U   Zope/trunk/lib/python/App/ProductContext.py

-=-
Modified: Zope/trunk/lib/python/App/ProductContext.py
===================================================================
--- Zope/trunk/lib/python/App/ProductContext.py	2005-10-31 21:01:54 UTC (rev 39792)
+++ Zope/trunk/lib/python/App/ProductContext.py	2005-10-31 21:23:13 UTC (rev 39793)
@@ -15,28 +15,32 @@
 $Id$
 """
 
+import os.path, re
+import stat
+
 from AccessControl.PermissionRole import PermissionRole
 import Globals, os, OFS.ObjectManager, OFS.misc_, Products
 import AccessControl.Permission
+from App.Product import doInstall
 from HelpSys import HelpTopic, APIHelpTopic
 from HelpSys.HelpSys import ProductHelp
 from FactoryDispatcher import FactoryDispatcher
 from zLOG import LOG, WARNING
-import os.path, re
-import stat
 from DateTime import DateTime
 from Interface.Implements import instancesOfObjectImplements
-from App.Product import doInstall
+from zope.interface import implementedBy
 
 import ZClasses # to enable 'PC.registerBaseClass()'
 
-if not hasattr(Products, 'meta_types'): Products.meta_types=()
+if not hasattr(Products, 'meta_types'):
+    Products.meta_types=()
 if not hasattr(Products, 'meta_classes'):
     Products.meta_classes={}
     Products.meta_class_info={}
 
 _marker = []  # Create a new marker object
 
+
 class ProductContext:
 
     def __init__(self, product, app, package):
@@ -100,7 +104,6 @@
            before calling an object's constructor.
 
         """
-        app=self.__app
         pack=self.__pack
         initial=constructors[0]
         productObject=self.__prod
@@ -110,8 +113,6 @@
             setattr(instance_class, 'icon', 'misc_/%s/%s' %
                     (pid, os.path.split(icon)[1]))
 
-        OM=OFS.ObjectManager.ObjectManager
-
         if permissions:
             if isinstance(permissions, basestring): # You goofed it!
                 raise TypeError, ('Product context permissions should be a '
@@ -140,6 +141,8 @@
             ((permission, (), default),))
         ############################################################
 
+        OM=OFS.ObjectManager.ObjectManager
+
         for method in legacy:
             if isinstance(method, tuple):
                 name, method = method
@@ -178,14 +181,26 @@
             if instance_class is None:
                 interfaces = ()
             else:
-                interfaces = instancesOfObjectImplements(instance_class)
+                interfaces = tuple(implementedBy(instance_class))
+                # BBB: Will be removed in Zope 2.11.
+                interfaces += tuple(instancesOfObjectImplements(instance_class))
 
         Products.meta_types=Products.meta_types+(
             { 'name': meta_type or instance_class.meta_type,
+              # 'action': The action in the add drop down in the ZMI. This is
+              #           currently also required by the _verifyObjectPaste
+              #           method of CopyContainers like Folders.
               'action': ('manage_addProduct/%s/%s' % (pid, name)),
+              # 'product': Used by ProductRegistry for TTW products and by
+              #            OFS.Application for refreshing products.
+              #            This key might not be available.
               'product': pid,
+              # 'permission': Guards the add action.
               'permission': permission,
+              # 'visibility': A silly name. Doesn't have much to do with
+              #               visibility. Allowed values: 'Global', None
               'visibility': visibility,
+              # 'interfaces': A tuple of oldstyle and/or newstyle interfaces.
               'interfaces': interfaces,
               'instance': instance_class,
               'container_filter': container_filter
@@ -211,7 +226,6 @@
                 setattr(OFS.misc_.misc_, pid, OFS.misc_.Misc_(pid, {}))
             getattr(OFS.misc_.misc_, pid)[name]=icon
 
-
     def registerZClass(self, Z, meta_type=None):
         #
         #   Convenience method, now deprecated -- clients should
@@ -237,8 +251,6 @@
         Products.meta_class_info[key]=info # meta_type
         Products.meta_classes[key]=Z
 
-
-
     def registerBaseClass(self, base_class, meta_type=None):
         #
         #   Convenience method, now deprecated -- clients should
@@ -249,7 +261,6 @@
         Z = ZClasses.createZClassForBase( base_class, self.__pack )
         return Z
 
-
     def getProductHelp(self):
         """
         Returns the ProductHelp associated with the current Product.
@@ -348,6 +359,7 @@
                 ht=APIHelpTopic.APIHelpTopic(file, '', os.path.join(path, file))
                 self.registerHelpTopic(file, ht)
 
+
 class AttrDict:
 
     def __init__(self, ob):



More information about the Zope-Checkins mailing list