[Zope] Search ZCatalog from Python code

douwe@oberon.nl douwe@oberon.nl
Fri, 14 Jun 2002 11:50:02 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C21399.9E867090
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: 7bit

Hi,

I'm affraid that I missed the start of this thread, as I only recently
joined. For me:

for catitem in self.Catalog.searchResults(meta_type='ContactItem',
Login=username):
      obj=self.Catalog.getobject(catitem.data_record_id_)

Seems to work just fine. self finds the catalogue by acquisition and from
there it is just like python in a zope script.

Douwe

  -----Original Message-----
  From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Ioannis
Koukos
  Sent: Friday, June 14, 2002 11:37 AM
  To: zope@zope.org
  Subject: Re: [Zope] Search ZCatalog from Python code


   My ZCatalog ("Catalog") is placed on the root folder. So, there is the
need to move back to retrieve and use it.

  Chris' snippet for the container object obviously doesn't work. Any help /
suggestion?

  Thanks

  Chris McDonough <chrism@zope.com> wrote

    Inside a class of a Zope Product:

    container = "self.aq_inner.aq_parent"
    context = self



    Ioannis Koukos wrote:
    > I've been trying to find documentation on how to search the ZCatalog
    > 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
    > products 'see' the context and container objects?






----------------------------------------------------------------------------
--
  Do You Yahoo!?
  A?ieo?ooa oci aunaUi oao @yahoo.gr aeayeoioc ooi Yahoo! Mail.


------=_NextPart_000_001C_01C21399.9E867090
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-7">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =

size=3D2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =
size=3D2>I'm=20
affraid that I missed the start of this thread, as I only recently =
joined. For=20
me:</FONT></SPAN></DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3D"Courier New" =
size=3D2>for catitem=20
in self.Catalog.searchResults(meta_type=3D'ContactItem',=20
Login=3Dusername):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
obj=3Dself.Catalog.getobject(catitem.data_record_id_)<BR></FONT></SPAN></=
DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =
size=3D2><SPAN=20
class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =
size=3D2>Seems to work=20
just fine. self finds the catalogue by acquisition and from there it is =
just=20
like&nbsp;python&nbsp;in a zope =
script.&nbsp;</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =
size=3D2><SPAN=20
class=3D505214609-14062002></SPAN></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =
size=3D2><SPAN=20
class=3D505214609-14062002>Douwe&nbsp;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=3D505214609-14062002><FONT face=3DArial color=3D#008080 =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #008080 2px =
solid">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> =
zope-admin@zope.org=20
  [mailto:zope-admin@zope.org]<B>On Behalf Of </B>Ioannis =
Koukos<BR><B>Sent:</B>=20
  Friday, June 14, 2002 11:37 AM<BR><B>To:</B> =
zope@zope.org<BR><B>Subject:</B>=20
  Re: [Zope] Search ZCatalog from Python code<BR><BR></FONT></DIV>
  <P>&nbsp;My ZCatalog&nbsp;("Catalog") is placed on the root =
folder.&nbsp;So,=20
  there is the need to move back&nbsp;to retrieve&nbsp;and use it.=20
  <P>Chris'&nbsp;snippet&nbsp;for the container object obviously doesn't =
work.=20
  Any help / suggestion?=20
  <P>Thanks=20
  <P><B><I>Chris McDonough &lt;chrism@zope.com&gt;</I></B> wrote=20
  <BLOCKQUOTE=20
  style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px =
solid">
    <P>Inside a class of a Zope Product:<BR><BR>container =3D=20
    "self.aq_inner.aq_parent"<BR>context =3D self<BR></P>
    <P><BR>Ioannis Koukos wrote:<BR>&gt; I've been trying to find =
documentation=20
    on how to search the ZCatalog <BR>&gt; from within a Zope product =
but there=20
    is a lack of documentation on that. <BR>&gt; Can this be done? If =
this is=20
    the case, how can external python <BR>&gt; products 'see' the =
context and=20
    container objects?<BR></P></BLOCKQUOTE>
  <P><BR>
  <HR SIZE=3D1>
  <B>Do You Yahoo!?</B><BR>=C1=F0=EF=EA=F4=DE=F3=F4=E5 =F4=E7=ED =
=E4=F9=F1=E5=DC=ED =F3=E1=F2 @yahoo.gr =E4=E9=E5=FD=E8=F5=ED=F3=E7 =
=F3=F4=EF <A=20
  href=3D"http://www.otenet.gr/">Yahoo! =
Mail</A>.<BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_001C_01C21399.9E867090--