[Zope3-dev] Page templates and macro extension

Fred Drake fdrake at gmail.com
Thu Aug 18 11:34:45 EDT 2005


Gary brought up an issue with the macro extension work that Shane did in the 
page templates code for Zope 3.1; the relevant code does not exist in Zope 
2.x or 3.0.x.  Gary's bug report is issue 440 in the Zope 3 collector:

    http://www.zope.org/Collectors/Zope3-dev/440

There appears to be a disagreement over the intended semantics.  Let's say we 
have the following templates:

           T1                       T2                     T3
  +-------------------+   +-------------------+   +-------------------+
  | define-macro M    |   | define-macro N    |   | use-macro T2/N    |
  |                   |   |   (extends T1/M)  |   |                   |
  |                   |   |                   |   |                   |
  |   define-slot A   |   |   fill-slot A     |   |                   |
  |                   |   |     define-slot A |   |   fill-slot A     |
  |                   |   |                   |   |                   |
  |   define-slot B   |   |   fill-slot B     |   |                   |
  |                   |   |                   |   |                   |
  +-------------------+   +-------------------+   +-------------------+

Note that T2 contains a construct like this:

    <div metal:fill-slot="A">
      some stuff
      <div metal:define-slot="A">
      </div>
    </div>

T3 should be filling the slot A defined in T2, and T2 should be filling the 
slot A defined in T1; this was not happening when T2 extended T1.  If T2 did 
not extend T1, but simply used it, this worked as expected.  Having this slot 
construct behave differently in the case of macro extension is confusing.

We (Gary and I) have a fix, but it broke three other tests.  I think one of 
the existing tests is wrong, but the other tests specifically check for the 
opposite of what we think should happen in the case of a slot filled by the 
extending macro.  Consider templates T1 and T2 above with the following T4:

           T4
  +-------------------+
  | use-macro T2/N    |
  |                   |
  |                   |
  |                   |
  |   fill-slot A     |
  |                   |
  |   fill-slot B     |
  |                   |
  +-------------------+

Here, T4 is attempting to fill a slot from T1 that's already been filled by 
T2.  The current tests require this behavior.  We'd like to change this, so 
that only slots offered by a macro or those it extends without filling them 
are available to users of the macro.  When macro extension is not being used, 
slot B can't be filled by T4, so this seems like an undesirable change 
because it introduces another inconsistency.

Given that the relevant feature (macro extension) is not included in Zope 
3.0.x, there are no backward compatibility issues for this change.  However, 
we'd like to get this right before the feature is released, else we won't be 
able to change it in the future.  The correct behavior for this feature needs 
to be determined (and properly documented!) before Zope 3.1.0 is released.


  -Fred

-- 
Fred L. Drake, Jr.  <fred at zope.com>
Zope Corporation


  -Fred

-- 
Fred L. Drake, Jr.   <fdrake at gmail.com>


More information about the Zope3-dev mailing list