[Zope-dev] Nesting Forms

Casey Duncan casey@zope.com
Thu, 18 Jul 2002 09:11:13 -0400


One approach might be to create a generic dtml (or zpt) template that has=
=20
several placeholders (in the form of <dtml-var> or tal:replace) for the a=
reas=20
of the form that will vary.

Then each subclass can override what goes in these placeholders if it cho=
oses.=20
Something like:

class A(Acquisition.Implicit):
    main =3D DTMLFile('foo', globals())
    sect1 =3D DTMLFile('Asect1', globals())
    sect2 =3D DTMLFile('Asect2', globals())

class B(A):
    sect1 =3D DTMLFile('Bsect1', globals())

class C(B):
    sect2 =3D DTMLFile('Csect2', globals())

class D(A):
    sect2 =3D DTMLFile('Dsect2', globals())

where main.dtml looks like:

<dtml-var standard_html_header>
=2E..
<dtml-var sect1>
=2E..
<dtml-var sect2>
=2E..
<dtml-var standard_html_footer>

The DTMLFile should acquire the correct version of sect1 and sect2 from i=
ts=20
parent instance above.

Asect1.dtml, Asect2.dtml, Bsect1.dtml, Csect2.dtml and Dsect2.dtml would =
all=20
be separate files.

hth,

Casey
   =20

On Wednesday 17 July 2002 05:50 pm, Ross Boylan wrote:
> I have a product with a number of classes that have subclasses.  It
> seems natural to make the screens for the subclasses by extending
> those of the superclass.  Can anyone suggest a good way to do that?
>=20
> The naive approach is that I have a manage_edit_A.dtml that gives a
> management screen for A.  If B subclasses A, I create
> manage_edit_B.dtml by copying from the first file and then fiddling
> with it.  Obviously, it would be desirable for a change in A to only
> require changing a single file.
>=20
> I would prefer a more elegant approach.  Perhaps I can define some
> method in A that the dtml will reference, and then B can override the
> method to add some extra stuff (the method would return a DTML
> snippet).
>=20
> First, I'm not exactly sure how to pick up the method from the DTML.
> Second, I'm not sure if this is the best solution.  For one thing, I
> would prefer to keep all my dtml in separate files, rather than
> defining it into my methods.
>=20
> Any suggestions?
>=20
> P.S. I'd like to thank Toby Dickenson, Casey Duncan, and R. David
> Murray for their very helpful responses to my previous question.
>=20
>=20
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>=20