[Zope] Display titles of containing folders

Tino Wildenhain tino@wildenhain.de
Tue, 27 Nov 2001 01:41:40 +0100


Hi,

--On Montag, 26. November 2001 21:15 +0100 Milos Prudek <milos.prudek@tiscali.cz> wrote:

> How can I display titles of folder, its parent folder etc. that contain
> a given ZClass if I iterate over a Catalog?
>
>
> Catalog_Art is a catalog of Articles.
>
> Given the following dtml method I would like to display the "path" to
> the article. Path means the titles of folders that the Article instance
> is located in:
>
> <table>
> <dtml-in Catalog_Art>
>   <tr><td><dtml-var mypath></td></tr>
> </dtml-in>
> </table>
>
> mypath is a Python Script that I cannot find a way to create :-( I head
> a good start:
>
> fullpath=context.getpath(context.data_record_id)
> fullpath=fullpath[1:]
> fullpath=string.replace(fullpath,"/",".")
> subfolder=fullpath[0:string.rfind(fullpath,".")]
> folder=subfolder[0:string.rfind(subfolder,".")]
>
> at this point folder=="folder_a" and subfolder=="folder_a.folder_aa".
> But what next? I cannot run folder_title=getattr(folder,"title"),
> because getattr does not work that way, and I cannot run eval(), because
> it is not allowed in Python Scripts.

Sure, but if you touch each object anyway, you dont need the catalog.
I can think of two ways to solve it a bit cleaner:
Record the title in the catalog, you can ilteratively search
for the sub paths which should give you only one result - the folder
along with its title.
The other way would be a method which returns your path title chain
as a string (in the ZClass) and catalog it with every object.

Regards
Tino