[Zope] Search ZCatalog from Python code

Chris McDonough chrism@zope.com
Thu, 13 Jun 2002 07:50:33 -0400

Inside a class of a Zope Product:

  container =3D "self.aq_inner.aq_parent"

  context =3D self

So if you have a ZCatalog named "Catalog" you could call the=20
searchResults method of "Catalog" from a Zope product like so:

catalog =3D self.Catalog # acquire the Catalog
results =3D catalog.searchResults({'meta_type':'foo'})


- C

Ioannis Koukos wrote:
> I've been trying to find documentation on how to search the ZCatalog=20
> from within a Zope product but there is a lack of documentation on that=
> Can this be done? If this is the case, how can external python=20
> products 'see' the context and container objects?
> Could there be an alternative solution based on the creation of a Pytho=
> Script inside Zope (thus binding the context-container) and then callin=
> it from the Product code? Same question for a DTML method.
> Regards,
> John
> =20
> -----------------------------------------------------------------------=
> *Do You Yahoo!?*
> =C1=F0=EF=EA=F4=DE=F3=F4=E5 =F4=E7=ED =E4=F9=F1=E5=DC=ED =F3=E1=F2 @yah=
oo.gr =E4=E9=E5=FD=E8=F5=ED=F3=E7 =F3=F4=EF Yahoo! Mail=20
> <http://www.otenet.gr/>.

Chris McDonough                    Zope Corporation
http://www.zope.org             http://www.zope.com
"Killing hundreds of birds with thousands of stones"