[Zope] Name of top level folder

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Sun, 13 Jun 1999 16:00:52 -0400 (EDT)


On Sun, 13 Jun 1999, Martijn Pieters wrote:

> At 12:32 11-6-99 , Alex.Thomas@dresdnerkb.com wrote:
> >Next challenge is to be a bit more selective about which documents are
> >displayed in the tree. For instance, could I not include objects with a
> >'dontIndex' property set by filtering the list that ObjectValues returns? No
> >idea how to code this, probably something to do with map or apply sorta
> >things, if anyone has the answer to hand this should keep me quiet for a
> >bit!
> 
> 
> If the objects must be the same type (for example, Folders), you must use
> an External Method. That external method can then filter the list or just
> create the list itself, before passing it back to the #tree tag object. If
> the External Method doesn't have any arguments, you can call it with the
> branches="" attribute, otherwise you'll have to use branches_expr="".
> 

A filtering external method is generally useful. You can add it on a top
level directory and call it from subobjects. Something like (untested):

def Filter(self,keyword):
    return filter(lambda a,b=keyword:not hasattr(a,b),self.objectValues())

You can then selectively return objects that have a given property. For
instance if you want to get all objects in a folder that have a property
'include_me_in_navbar' you could do:

<!--# in "Filter('include_me_in_navbar')" -->
...
<!--# /in-->

Pavlos