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! thanks a lot alex -----Original Message----- From: Alex.Thomas@dresdnerkb.com [mailto:Alex.Thomas@dresdnerkb.com] Sent: 11 June 1999 03:31 To: zope@zope.org Subject: RE: [Zope] Name of top level folder Ah, brilliant - the expr keyword comes to the rescue. Many thanks, don't think I would have found that for a long time. As I'm now indebted to you and the list, I might make the very modest contribution of the DTML that makes the multiline tree headings line up neatly. Well, it's a start... cheers alex -----Original Message----- From: Alexander Staubo [mailto:alex@mop.no] Sent: 11 June 1999 02:49 To: Zope Mailing List (E-mail) Subject: RE: [Zope] Name of top level folder You might be confusing "name" with "id" or "title". You're right, the root object does not have a name, but that should stop you from including it in iterations, or the tree tag. To tell the #tree tag to start at the top, do: <!--#tree expr="PARENTS[-1]"--> <!--#var title_or_id--> <!--#/tree--> Note that, for obvious reasons, the top level will not be included in the tree. (If you're wondering how the hierarchical tree seen in the Zope management screens manages to include the root object, this isn't a trick performed just with the #tree tag. See zope/lib/python/Ap/menu.dtml for the DTML code.) -- Alexander Staubo http://www.mop.no/~alex/ "`Ford, you're turning into a penguin. Stop it.'" --Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Alex.Thomas@dresdnerkb.com Sent: 11. juni 1999 02:34 To: zope@zope.org Subject: RE: [Zope] Name of top level folder
If I have a document http:/mysite/index_html then if that document calls #tree I think PARENTS[0] would be the name of the top level folder. However, I can't use it (or PARENTS[-1] etc.) - raises a KeyError - so I suspect that there is no name for this folder, which is a bit of a shame...
alex
-----Original Message----- From: Alexander Staubo [mailto:alex@mop.no] Sent: 11 June 1999 01:33 To: Zope Mailing List (E-mail) Subject: RE: [Zope] Name of top level folder
PARENTS[-1] will get you the top-level folder object, if that's what you're asking.
-- Alexander Staubo http://www.mop.no/~alex/ "`Ford, you're turning into a penguin. Stop it.'" --Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Alex.Thomas@dresdnerkb.com Sent: 10. juni 1999 23:36 To: zope@zope.org Subject: [Zope] Name of top level folder
OK, an easy one - what's the Name of the top level folder? I need it to pass to the #tree tag so it displays the whole structure.
Thanks!
alex ########################################## This email, its content and any files transmitted with it are intended solely for the addressee(s) and may be legally privileged and/or confidential. Access by any other party is unauthorised without the express written permission of the sender. If you have received this email in error you may not copy or use the contents, attachments or information in any way. Please destroy it and contact the sender on the number printed above, via the Dresdner Kleinwort Benson switchboard on +44 171 623 8000 or via e-mail return. Internet communications are not secure unless protected using strong cryptography. This email has been prepared using information believed by the author to be reliable and accurate, but Dresdner Kleinwort Benson makes no warranty as to accuracy or completeness. In particular Dresdner Kleinwort Benson does not accept responsibility for changes made to this email after it was sent. Any opinions expressed in this document are those of the author and do not necessarily reflect the opinions of the Bank or its affiliates. They may be subject to change without notice. ##########################################
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 objetcs you want to exclude are documents, you could differntiate between DTML Methods and DTML Documents, and have objectValues only return one ore the other. 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="". I didn't test this, but you could maybe define a meta_type property on a Folder. The objectValues, objectItems and objectIds methods filter on that property. Defining the property on a Folder might override the default value of 'Folder'. You can then instruct objectValues to only return objects of type 'TreeFolder' or something. I don't know if 1) you can override the property, and 2) what the side effects will be. YMMV. In Zope 2, you could subclass Folders using ZClasses, and only change the meta_type. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
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
participants (3)
-
Alex.Thomas@dresdnerkb.com -
Martijn Pieters -
Pavlos Christoforou