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? Could there be an alternative solution based on the creation of a Python Script inside Zope (thus binding the context-container) and then calling it from the Product code? Same question for a DTML method. Regards, John --------------------------------- Do You Yahoo!? Αποκτήστε την δωρεάν σας@yahoo.gr διεύθυνση στο Yahoo! Mail.
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?
It could look something like:: def doSearch(self, REQUEST=None, **kw) result = [] for resultItem in self.Catalog(REQUEST, **kw) # call object as a function! result.append(self.Catalog.getobject(resultItem.data_record_id_)) return result # get Folders for folder in doSearch(meta_type='Folder') print folder.title_or_id() But this "awakens" all the objects and can be an expensive way of doing it. Modify for your own amusement. Look in the Zope Books API reference for more info. regards Max M -- "Sorry I would Really Like To Help More On This Project, But Am To Busy Doing Paid Work On A Tight Deadline" Max M
Inside a class of a Zope Product: container = "self.aq_inner.aq_parent" context = self So if you have a ZCatalog named "Catalog" you could call the searchResults method of "Catalog" from a Zope product like so: catalog = self.Catalog # acquire the Catalog results = catalog.searchResults({'meta_type':'foo'}) HTH, - C 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?
Could there be an alternative solution based on the creation of a Python Script inside Zope (thus binding the context-container) and then calling it from the Product code? Same question for a DTML method.
Regards,
John
------------------------------------------------------------------------ *Do You Yahoo!?* Αποκτήστε την δωρεάν σας @yahoo.gr διεύθυνση στο Yahoo! Mail <http://www.otenet.gr/>.
-- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"
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.
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.
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.
participants (4)
-
Chris McDonough -
douwe@oberon.nl -
Ioannis Koukos -
Max M