[Zope] my solution to #include in DocumentTemplate

Tino Wildenhain tino@wildenhain.de
Mon, 14 May 2001 11:32:35 +0200


Hi Lance,

if you are on a tight deadline, why dont you start
using zope rather then hacking around with plain files? ;)

Regards
Tino Wildenhain

--On Freitag, 11. Mai 2001 14:22 -0400 Lance E Sloan <lsloan@umich.edu> 
wrote:

>
> Just in case anybody is interested (rather unlikely) I thought
> I'd let everybody know how I resolved my quest for #include-like
> behavior in DocumentTemplate.  Of course, a very good way would
> have been to actually create a "dtml-include" tag by following
> the suggestions at zope.org.
>
> Being a Python newbie, a Zope not-even-newbie-yet, and under a
> tight deadline, I didn't go that route.  Instead, I happened
> to stumble across this method.  What I was looking for was
> something like:
>
> 	<!--#include file="../path/to/filename.dtml" -->
>
> in a DTML file to include another DTML file, recursively.  I
> ended up doing this:
>
> 	<!--#with "_(incDoc = DocumentTemplate.HTMLFile('../path/to/file.dtml'))"
> 	-->
> 	<!--#var expr="incDoc(x = x)" -->
> 	<!--#/with -->
>
> It works well.  The only problem is that for every object I want
> to pass to the included document must be specified individually
> (x = x).  I tried these but they didn't work:
>
> 	<!--#var expr="incDoc(mapping = vars())" -->
> 	<!--#var expr="incDoc(mapping = mapping)" -->
>
> For now, this is not too much of a problem, as I'm only including
> a header or a footer that's common to all my DTML pages and they
> don't require many arguments.
>
> BTW, I think DocumentTemplate is excellent and it should be added to
> the standard Python distribution.  For those that don't know my
> weird history with this module, I've borrowed DocumentTemplate from
> Zope to write some CGIs in Python.  They're coming along nicely,
> but I admit that I'm somewhat sloppy.
>
> --
> Lance E Sloan
> Web Services, Univ. of Michigan: Full-service Web and database design,
> development, and hosting.  Specializing in Perl & Python CGIs.
> http://websvcs.itd.umich.edu/ - "Putting U on the Web"
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> 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 )