[Zope] Search ZCatalog from Python code

Ioannis Koukos ioanniskoukos@yahoo.gr
Fri, 14 Jun 2002 14:10:49 +0100 (BST)


--0-317426449-1024060249=:10101
Content-Type: text/plain; charset=iso-8859-7
Content-Transfer-Encoding: 8bit


The problem is that the Catalog cannot be found through acquisition. I can't figure out why. I can perfectly use the Catalog from DTMLs in the Product but there is no way Catalog can be found from within Python, ie "self.Catalog" does not work. Printing the 'self' reveals that it is an instance of the caller Python class. What can be done to make 'self' acquire from parents?
Regards,
Ioannis
douwe@oberon.nl έγραψε: 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!?
Αποκτήστε την δωρεάν σας@yahoo.gr διεύθυνση  στο Yahoo! Mail.

--0-317426449-1024060249=:10101
Content-Type: text/html; charset=iso-8859-7
Content-Transfer-Encoding: 8bit

<P>The problem is that the Catalog cannot be found through acquisition. I can't&nbsp;figure out&nbsp;why. I can perfectly use the Catalog from DTMLs in the Product but there is no way Catalog can be found from within Python, ie "self.Catalog" does not work. Printing the 'self' reveals that it is an instance of the caller Python class. What can be done to make 'self' acquire from parents?
<P>Regards,
<P>Ioannis
<P><B><I><A href="mailto:douwe@oberon.nl">douwe@oberon.nl</A></I></B> έγραψε: 
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2>I'm affraid that I missed the start of this thread, as I only recently joined. For me:</FONT></SPAN></DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=505214609-14062002><FONT face="Courier New" size=2>for catitem in self.Catalog.searchResults(meta_type='ContactItem', Login=username):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; obj=self.Catalog.getobject(catitem.data_record_id_)<BR></FONT></SPAN></DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2>Seems to work just fine. self finds the catalogue by acquisition and from there it is just like&nbsp;python&nbsp;in a zope script.&nbsp;</FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2><SPAN class=505214609-14062002></SPAN></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2><SPAN class=505214609-14062002>Douwe&nbsp;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=505214609-14062002><FONT face=Arial color=#008080 size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #008080 2px solid">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> zope-admin@zope.org [mailto:zope-admin@zope.org]<B>On Behalf Of </B>Ioannis Koukos<BR><B>Sent:</B> Friday, June 14, 2002 11:37 AM<BR><B>To:</B> zope@zope.org<BR><B>Subject:</B> 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, there is the need to move back&nbsp;to retrieve&nbsp;and use it. 
<P>Chris'&nbsp;snippet&nbsp;for the container object obviously doesn't work. Any help / suggestion? 
<P>Thanks 
<P><B><I>Chris McDonough &lt;chrism@zope.com&gt;</I></B> wrote 
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<P>Inside a class of a Zope Product:<BR><BR>container = "self.aq_inner.aq_parent"<BR>context = self<BR></P>
<P><BR>Ioannis Koukos wrote:<BR>&gt; I've been trying to find documentation on how to search the ZCatalog <BR>&gt; from within a Zope product but there is a lack of documentation on that. <BR>&gt; Can this be done? If this is the case, how can external python <BR>&gt; products 'see' the context and container objects?</P></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE><p><br><hr size=1><b>Do You Yahoo!?</b><br>Αποκτήστε την δωρεάν σας
@yahoo.gr διεύθυνση  στο 
<a href="http://www.otenet.gr/">Yahoo! Mail</a>.<br>
--0-317426449-1024060249=:10101--