[Zope] dtml-with and only

Barry A. Warsaw bwarsaw@cnri.reston.va.us (Barry A. Warsaw)
Wed, 3 Nov 1999 12:01:14 -0500 (EST)


I'm sure this is a newbie question, so go easy on me :)

Anyway, I've finally gotten around to mocking up the python.org
website in Zope.  I saw some neat code called Breadcrumbs which
includes a list of parent links to the page you're sitting on, e.g.

Home > Community > On-line PSA Registration

Naturally, I modified the DTML to do things a little differently, and
one of the things I want to do is to be able to add title
abbreviations (i.e. nicknames) to some folders, using them in
preference to title or id (I want a sort of nickname_or_title_or_id
method).  So the idea is to add a property to some folders called
`nickname' and use that if it exists, otherwise use the title_or_id.

The problem of course is that I do not want `nickname' to be
acquired.  I figured I could write DMTL like the following to
accomplish this:

-------------------- snip snip --------------------
<dtml-with folderobj only>
   <dtml-if nickname><dtml-var nickname>
   <dtml-else><dtml-var title_or_id>
   </dtml-else>
</dtml-with>
-------------------- snip snip --------------------

From the docs, it seems that the `only' tag should stop the name
search in enclosing namespaces, but this doesn't seem to work.  In my
root folder, I include a nickname property, and set it to "Home".  In
a subfolder (say "psa") I do not have a nickname property, but this
DTML method is returning "Home" for both folder objects.

I've also tried substituting the dtml-if test with something like

    <dtml-if "_.hasattr(folderobj, 'nickname')">

but that didn't seem to make a difference.

Is this enough information to help?  I'm sure I'm either
misunderstanding some simple concept or doing some dumb newbie lose.
Any help will be appreciated.

Thanks,
-Barry