[Zope-Checkins] CVS: Zope/lib/python/OFS - ObjectManager.py:1.145.16.1

Andreas Jung andreas@digicool.com
Wed, 13 Feb 2002 10:14:14 -0500


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv11911/lib/python/OFS

Modified Files:
      Tag: Zope-2_5-branch
	ObjectManager.py 
Log Message:
      - Collector #166: ObjectManger.all_meta_types() implemented only
        an incomplete filter based on interfaces.


=== Zope/lib/python/OFS/ObjectManager.py 1.145 => 1.145.16.1 ===
 
     def all_meta_types(self, interfaces=None):
-        pmt=()
-        if hasattr(self, '_product_meta_types'): pmt=self._product_meta_types
+        _pmt=()
+        if hasattr(self, '_product_meta_types'): _pmt=self._product_meta_types
         elif hasattr(self, 'aq_acquire'):
-            try: pmt=self.aq_acquire('_product_meta_types')
+            try: _pmt=self.aq_acquire('_product_meta_types')
             except:  pass
+
+        if interfaces is None:  pmt = list(_pmt)
+        else:
+            pmt = []
+
+            for entry in pmt:
+                try:
+                    eil = entry.get('interfaces',None)
+
+                    if eil is not None:
+                        for ei in eil:
+                            for i in interfaces: 
+                                if ei is i or ei.extends(i):
+                                    pmt.append(entry) 
+                                    raise BreakoutException # only append 1ce
+                except BreakoutException:   
+                    pass
             
         gmt = []
 
@@ -175,7 +192,7 @@
                 except BreakoutException:   
                     pass
 
-        return list(self.meta_types)+gmt+list(pmt)
+        return list(self.meta_types)+gmt+pmt
 
     def _subobject_permissions(self):
         return (Products.__ac_permissions__+