[Zope] How to make a script return rendered dtml

Eric Balasbas ebalasba@bway.net
Wed, 13 Jun 2001 11:33:33 -0400 (EDT)


I'm not sure if this is the best way to do it, but if you want to render a
DTML method or DTML document inside a Python script, use the syntax:

someDTMLMethod(_.None, _)



Eric Balasbas
Senior Developer
eric@virtosi.com

http://www.virtosi.com/
Virtosi Ltd.
Design -- Branding -- Zope


On Wed, 13 Jun 2001, Tim Hicks wrote:

> I have a ZClass (testclass) which subclasses DTMLDocument, and within this
> zclass, I have a script (python) called index_html.  Obviously, this script
> is called each time an instance of testclass is requested.  Based on the
> presence of a query string, I want to either return the document_src
> (although with a few modifications), or simply return the rendered
> instance... by this, I mean have all the dtml tags that are in the instance
> evaluated.  So, my question is, how do I make Zope evaluate the dtml tags?
>
> Here is what I have so far in my script:
>
> ------------
> if context.REQUEST.QUERY_STRING == 'editor':
>     print context.raw
> else:
>     print context
>
> return printed
> ------------
>
> The 'else' statement simply gives me things like,
>
> <dtml-var standard_html_header>
>
> I also tried 'else: render(context)', which was simply a guess on my part,
> but I get a Zope error as follows:
>
> Error Type: AttributeError
> Error Value: validate
>
> Can anyone enlighten me?
>
> Cheers
>
> tim
>
>
> _______________________________________________
> 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 )
>