[Zope] Using REQUEST only in a limited fashion

Dieter Maurer dieter@handshake.de
Fri, 8 Jun 2001 20:18:26 +0200 (CEST)


Anders Schneiderman writes:
 > ... determining that an object has an unacquired attribute ...
This is currently not easy.

You can try:

    <dtml-if "_.has_key(aq_explicit,'front_page')">
      ...

This will often work, but sometimes give false "true" results.


A safe method is to write an External Method "has" with the following code:

  def has(object,attr):
    object= getattr(object,'aq_base',object)
    return hasattr(object,attr)

and use is as follows:

    <dtml-if "has(this(),'font_page')">
      ...


Dieter