[Zope] DTML rendering from python?
Dylan Reinhardt
Dylan@DylanReinhardt.com
Wed, 22 Jan 2003 09:19:54 -0800
At 07:38 AM 1/22/2003, Michiel Toneman wrote:
>The
>problem is that the DTML tag I add to the output of getHTML doesn't get
>rendered in my DTML Document when I call the object.
I hate when people on a programming list answer a simple question by
telling the poster not to do something the way they're doing it, but here
goes: Don't do it that way.
DTML and ZPT are available for rendering HTML. Don't do it in your product
code. Just don't. Seriously, don't.
In a product, it's a far better strategy to define your user interface by
using ZPT or DTML in stand-alone files in the product folder. It would
appear you already know how to set up and call such pages, but allow me to
suggest a couple things.
First, use:
index_html = DTMLFile('dtml/viewArticlePage', globals())
There's no good reason to call the extra function. If viewArticlePage
needs additional logic, call something in your product.
Second, use DTML how it's designed, namely for inserting dynamic
information into a pre-defined layout. Re-factor until *all* of your HTML
is done in a templating language and your product only contains non-layout
data. Seriously... not one extra in your data!
Having done that, your user interfaces will stay isolated while you focus
on using Python for the truly important/difficult stuff like getting your
security assertions right, managing your data and performing your logic
correctly.
I doubt that was the answer you were looking for, but I suspect it's the
one you will find most helpful in the long run. I made the mistake of
doing all my HTML rendering in code in my first real product and I ended up
regretting it deeply.
Dylan