[Zope-Checkins] CVS: Zope/lib/python/OFS - FindSupport.py:1.25.2.1

Brian Lloyd brian@digicool.com
Tue, 25 Sep 2001 11:14:51 -0400


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

Modified Files:
      Tag: Zope-2_4-branch
	FindSupport.py 
Log Message:
Added fix to find support to find objects inside of ZClasses. Thanks 
to Anthony Baxter for the patch.


=== Zope/lib/python/OFS/FindSupport.py 1.25 => 1.25.2.1 ===
             base=obj.aq_base
 
-        if not hasattr(base, 'objectItems'):
-            return result
-        try:    items=obj.objectItems()
-        except: return result
+        if hasattr(base, 'objectItems'):
+	    try:    items=obj.objectItems()
+	    except: return result
+        else:
+            if getattr(base, 'meta_type', None) == 'Z Class':
+		try:    items=obj.propertysheets.methods.objectItems()
+		except: return result
+            else:
+		return result
 
         try: add_result=result.append
         except:
@@ -194,14 +199,21 @@
                 ):
                 add_result((p, ob))
                 dflag=0
-                    
-            if search_sub and hasattr(bs, 'objectItems'):
-                self.ZopeFind(ob, obj_ids, obj_metatypes,
+
+            is_zclass = getattr(bs, 'meta_type', None) == 'Z Class'
+            if search_sub and (hasattr(bs, 'objectItems') or is_zclass):
+                if is_zclass:
+                    subob = ob.propertysheets.methods
+                    sub_p = '%s/propertysheets/methods' % p
+                else:
+                    subob = ob
+                    sub_p = p
+                self.ZopeFind(subob, obj_ids, obj_metatypes,
                                    obj_searchterm, obj_expr,
                                    obj_mtime, obj_mspec,
                                    obj_permission, obj_roles,
                                    search_sub,
-                                   REQUEST, result, p)
+                                   REQUEST, result, sub_p)
             if dflag: ob._p_deactivate()
 
         return result