[Zope-dev] Nesting Forms

Ross Boylan RossBoylan@stanfordalumni.org
Thu, 18 Jul 2002 11:06:43 -0700


Is there a way to get inheritance, so that, for example, 
class C(B):
      sect1 = DTMLFile("CSect2",globals())+B.sect1(self)?

I don't think that syntax will work, but perhaps you see what I'm
driving at--I want to include all the  previous stuff.

On Thu, Jul 18, 2002 at 09:11:13AM -0400, Casey Duncan wrote:
> One approach might be to create a generic dtml (or zpt) template that has 
> several placeholders (in the form of <dtml-var> or tal:replace) for the areas 
> of the form that will vary.
> 
> Then each subclass can override what goes in these placeholders if it chooses. 
> Something like:
> 
> class A(Acquisition.Implicit):
>     main = DTMLFile('foo', globals())
>     sect1 = DTMLFile('Asect1', globals())
>     sect2 = DTMLFile('Asect2', globals())
> 
> class B(A):
>     sect1 = DTMLFile('Bsect1', globals())
> 
> class C(B):
>     sect2 = DTMLFile('Csect2', globals())
> 
> class D(A):
>     sect2 = DTMLFile('Dsect2', globals())
> 
> where main.dtml looks like:
> 
> <dtml-var standard_html_header>
> ...
> <dtml-var sect1>
> ...
> <dtml-var sect2>
> ...
> <dtml-var standard_html_footer>
> 
> The DTMLFile should acquire the correct version of sect1 and sect2 from its 
> parent instance above.
> 
> Asect1.dtml, Asect2.dtml, Bsect1.dtml, Csect2.dtml and Dsect2.dtml would all 
> be separate files.
> 
> hth,
> 
> Casey
>     
> 
> 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?
> > 
> > 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.
> > 
> > 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).
> > 
> > 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.
> > 
> > Any suggestions?
> > 
> > P.S. I'd like to thank Toby Dickenson, Casey Duncan, and R. David
> > Murray for their very helpful responses to my previous question.
> > 
> > 
> > _______________________________________________
> > Zope-Dev maillist  -  Zope-Dev@zope.org
> > http://lists.zope.org/mailman/listinfo/zope-dev
> > **  No cross posts or HTML encoding!  **
> > (Related lists - 
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope )
> > 
> 
>