Steve Alexander writes:
 > >  * 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>
It may work for "PARENTS[-1]" but it can not be generalized:

  The DTML namespace is essentially a stack of mappings.
  The "with" tag with the "only" attribute starts a new
  stack and pushes the object onto this new stack.
  Inside the "with", you will only see attributes of
  the object itself *or* attributes that the object
  acquired. This "or" is the problem.

  Acquisition and namespace stacking are orthogonal.
  You strip the namespace stacking with the "only"
  attribute (of the "with" tag), you strip the acquisition context with
  the "aq_base" attribute (of the object).


Dieter

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to