[Zope-Checkins] CVS: Zope2 - ProductContext.py:1.33

shane@digicool.com shane@digicool.com
Fri, 1 Jun 2001 12:19:37 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/App
In directory korak.digicool.com:/tmp/cvs-serv26278

Modified Files:
	ProductContext.py 
Log Message:
Modified the drop-in registry to make use of instancesOfObjectImplements().
This ensures the interfaces are returned as a list and isolates knowledge of
the "__implements__" attribute.



--- Updated File ProductContext.py in package Zope2 --
--- ProductContext.py	2001/05/30 15:57:30	1.32
+++ ProductContext.py	2001/06/01 16:19:37	1.33
@@ -95,6 +95,7 @@
 import stat
 from DateTime import DateTime
 from types import ListType, TupleType
+from Interface import instancesOfObjectImplements
 
 import ZClasses # to enable 'PC.registerBaseClass()'
 
@@ -103,6 +104,8 @@
     Products.meta_classes={}
     Products.meta_class_info={}
 
+_marker = []  # Create a new marker object
+
 class ProductContext:
 
     def __init__(self, product, app, package):
@@ -110,25 +113,10 @@
         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__
+                      visibility="Global",interfaces=_marker
         ):
         """Register a constructor
 
@@ -241,8 +229,8 @@
         if not hasattr(pack, '_m'): pack._m=fd.__dict__
         m=pack._m
 
-        if interfaces is self.__marker__:
-            interfaces = getattr(instance_class, "__implements__", None)
+        if interfaces is _marker:
+            interfaces = instancesOfObjectImplements(instance_class)
 
         Products.meta_types=Products.meta_types+(
             { 'name': meta_type or instance_class.meta_type,