[Zope] Surprises with dtml-in and dtml-with

Dieter Maurer dieter@handshake.de
Thu, 5 Apr 2001 21:05:50 +0200 (CEST)


Shai Berger writes:
 > I found a very peculiar behvaior in the interaction
 > between dtml-with and dtml-in.....

 > <dtml-in QueryA>
 >   ....
 >   <dtml-in QueryB>
 >     <dtml-with Folder3>
 >        ...access common fields...

 > Now, to my surprise, it turns out that when common fields
 > are accessed as shown above, QueryA takes precedence. To
 > my even greater surprise, it turns out that ...
 > <dtml-in QueryA>
 >   ....
 >   <dtml-with Folder3>
 >     <dtml-in QueryB>
 >        ...access common fields...
 > Restores predicted behavior (i.e. QueryB results take precedence).

 > Has anyone seen behavior like this? Can anyone explain it?
Yes, it came up already in the list:

  It is probably an interesting acquisition effect

    * the current object of an "in" interation is pushed
      onto the DTML namespace wrapped into
      an "InstanceDict"

    * if the current object came from a Z SQL query,
      then its acquisition context is set to the Z SQL query.

  It seems that your "Folder3" above is found via
  the current object of the "QueryA" iteration.
  Therefore, this object forms the acquisition context
  of "Folder3".
  The rest is easy:

    With "Folder3" on top of the DTML namespace,
    it is ask first for the "common fields".
    It does not have them itself and asks its
    acquisition context, the "QueryA" interation
    object. This happily provides its values.

    With "in" and "with" interchanged, the
    "QueryB" iteration object is on top of the
    namespace and resolves the names.



Dieter