[Zope-dev] [patch] making 'Find' traverse into ZClass Products

Anthony Baxter anthony@interlink.com.au
Fri, 21 Sep 2001 16:21:33 +1000


------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <3690.1001053293.1@mbuna>

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


------- =_aaaaaaaaaa0
Content-Type: text/x-patch; charset="us-ascii"
Content-ID: <3690.1001053293.2@mbuna>
Content-Description: FindSupport.py.patch
Content-Transfer-Encoding: quoted-printable

Index: FindSupport.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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=3Dobj.aq_base
 =

-        if not hasattr(base, 'objectItems'):
-            return result
-        try:    items=3Dobj.objectItems()
-        except: return result
-
+        if hasattr(base, 'objectItems'):
+	    try:    items=3Dobj.objectItems()
+	    except: return result
+	else:
+	    if base.meta_type =3D=3D "Z Class":
+		try:    items=3Dobj.propertysheets.methods.objectItems()
+		except: return result
+	    else:
+		return result
+		=

         try: add_result=3Dresult.append
         except:
             raise AttributeError, `result`
@@ -195,13 +200,21 @@
                 add_result((p, ob))
                 dflag=3D0
                     =

-            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 =3D=3D "Z Class") :
+		if bs.meta_type =3D=3D "Z Class":
+		    subob =3D ob.propertysheets.methods
+		    sub_p =3D '%s/propertysheets/methods'%p
+		else:
+		    subob =3D ob
+		    sub_p =3D 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

------- =_aaaaaaaaaa0--