[Zope] Re: [Zope-dev] Need for "aq_base" in DTML(was: Re: [Zope] Dumb DTML question - existance check of an object)(was: Re: [Zope] Dumb DTML question - existance check of an object) question - existance check of an object)(was: Re: [Zope] Dumb DTML question - existance check of an object)

Steve Alexander steve@cat-box.net
Wed, 26 Jul 2000 22:34:00 +0100


Dieter Maurer wrote:
> 
>  * Access to "/": "PARENTS[-1]"
>  * Existence check: "_.hasattr(object,what)"
>      NOTE, that this is the sloppy part.
> 
>       - "_.hasattr" will return true, if "object" has
>         attribute "what" (that is what we want)
>         *OR* when it has acquired such an attribute
>         (we do *NOT* want that here).
> 
>         What we would need is a DTML accessible version
>         of "aq_base". This is trivially handled by
>         an external method.

Can you do this with the following in DTML?

  <dtml-with "PARENTS[-1]" only>
    <dtml-if "_.hasattr(object, what)">
        ...stuff...
    </dtml-if>
  </dtml-with>

Not tested, but it looks right to me.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net