[Zope-Checkins] CVS: Zope2 - Product.py:1.50 ProductContext.py:1.32

andreas@serenade.digicool.com andreas@serenade.digicool.com
Wed, 30 May 2001 11:58:01 -0400


Update of /cvs-repository/Zope2/lib/python/App
In directory serenade:/tmp/cvs-serv21362/lib/python/App

Modified Files:
	Product.py ProductContext.py 
Log Message:
merged ajung-dropin-registry branch


--- Updated File Product.py in package Zope2 --
--- Product.py	2001/05/17 18:35:08	1.49
+++ Product.py	2001/05/30 15:57:30	1.50
@@ -216,7 +216,15 @@
     def __init__(self, id, title):
         self.id=id
         self.title=title
-        self._setObject('Help', ProductHelp('Help', id))
+
+        # Workaround for unknown problem with help system and PluginIndexes product
+        # NEEDS to be fixed for 2.4 ! (ajung)
+
+        try:
+            self._setObject('Help', ProductHelp('Help', id))
+        except:
+            print 'Warning: self._setObject() failed for %s/%s' % (id,title)
+            pass
         
     def Destination(self):
         "Return the destination for factory output"

--- Updated File ProductContext.py in package Zope2 --
--- ProductContext.py	2001/03/27 03:18:08	1.31
+++ ProductContext.py	2001/05/30 15:57:30	1.32
@@ -94,6 +94,7 @@
 import string, os.path, re
 import stat
 from DateTime import DateTime
+from types import ListType, TupleType
 
 import ZClasses # to enable 'PC.registerBaseClass()'
 
@@ -109,9 +110,25 @@
         self.__app=app
         self.__pack=package
 
+    def _flattenInterfaces(self, interfaces):
+        """Flatten an interface description into a list"""
+
+        list = []
+        ti = type(interfaces)
+        if ti == ListType or ti == TupleType:
+            for entry in interfaces:
+                for item in self._flattenInterfaces(entry):
+                    list.append(item)
+        else:
+            list.append(interfaces)
+        return list
+
+    __marker__ = []
+
     def registerClass(self, instance_class=None, meta_type='', 
                       permission=None, constructors=(),
                       icon=None, permissions=None, legacy=(),
+                      visibility="Global",interfaces=__marker__
         ):
         """Register a constructor
 
@@ -151,6 +168,10 @@
         legacy -- A list of legacy methods to be added to ObjectManager
                   for backward compatibility
 
+        visibility -- "Global" if the object is globally visible, None else
+
+        interfaces -- a list of the interfaces the object supports
+
         """
         app=self.__app
         pack=self.__pack
@@ -220,11 +241,17 @@
         if not hasattr(pack, '_m'): pack._m=fd.__dict__
         m=pack._m
 
+        if interfaces is self.__marker__:
+            interfaces = getattr(instance_class, "__implements__", None)
+
         Products.meta_types=Products.meta_types+(
             { 'name': meta_type or instance_class.meta_type,
               'action': ('manage_addProduct/%s/%s' % (pid, name)),
               'product': pid,
               'permission': permission,
+              'visibility': visibility,
+              'interfaces': interfaces,
+              'instance': instance_class,
               },)
 
         m[name]=initial