[Zope] Re: Preserving Context

Javier Subervi javier_subervi at yahoo.com
Wed Dec 13 06:09:17 EST 2006


From: Jonathan <dev101 at ...>

> targetFolder = string.join(traverse_subpath, '/') #you will have to play with this to get the right target folder for your app
> aFolder = context.restrictedTraverse(targetFolder)
> searchRes = aFolder.Catalog(<some search string here>)
> <do something with search results here>

First of all, thank you very much for your help.
I'm confused. I had a programmer working for me that wrote the following code:

return 0
catalog = ''
try:
    catalog = getattr(context, context.superValues('ZCatalog')[0].id)
except AttributeError:
    pass
if catalog:
return 1

Now, that works just fine if I leave the page template that calls it in the folder of a specific Web site. But when I put that template in a "root" folder that all the Web sites of the portal can call, it only gives me a printout of the tree of what's in the root folder. What I'm trying to accomplish is that it gives me the tree of the specific Web site folder from which it is called.

My problem is that I frankly don't understand what my programmer wrote...how it works. Research taught me that "superValues" returns the meta_data of ZCatalog, we're popping the first element of the tuple, getting it's ID, all in context of the call, and calling that a catalog. But why do we return "1" if we get a catalog? How does that print the catalog? Then, how do I incorporate your information to achieve my goal?
Thanks for any help you care to offer,
Javier


 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20061213/8b45ae11/attachment.htm


More information about the Zope mailing list