I got completely fed up with the Zope 'Find' stuff not being about to
traverse through Products/Foo/FooProduct, where FooProduct is a ZClass.
The following patch adds this support to the FindSupport.ZopeFind method
through the simple fix of saying "if it's a ZClass, keep looking in
ob.propertysheets.methods"
It seems to Work For Me - I'd post it to the collector, but I can't reach
it at the moment...
Anthony
Index: FindSupport.py
===================================================================
RCS file: /export/00/cvsroot/Zope/lib/python/OFS/FindSupport.py,v
retrieving revision 1.1.1.5
diff -u -u -r1.1.1.5 FindSupport.py
--- FindSupport.py 2001/09/21 04:25:43 1.1.1.5
+++ FindSupport.py 2001/09/21 06:15:53
@@ -152,11 +152,16 @@
if hasattr(obj, 'aq_base'):
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 base.meta_type == "Z Class":
+ try: items=obj.propertysheets.methods.objectItems()
+ except: return result
+ else:
+ return result
+
try: add_result=result.append
except:
raise AttributeError, `result`
@@ -195,13 +200,21 @@
add_result((p, ob))
dflag=0
- if search_sub and hasattr(bs, 'objectItems'):
- self.ZopeFind(ob, obj_ids, obj_metatypes,
+ if search_sub and ( hasattr(bs, 'objectItems') or
+ bs.meta_type == "Z Class") :
+ if bs.meta_type == "Z Class":
+ 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