[Zope] How to make a script return rendered dtml

Tim Hicks tim@sitefusion.co.uk
Wed, 13 Jun 2001 17:08:56 +0100


----- Original Message -----
From: "Peter Bengtsson" <mail@peterbe.com>
To: "Tim Hicks" <tim@sitefusion.co.uk>
Cc: <zope@zope.org>
Sent: Wednesday, June 13, 2001 3:59 PM
Subject: Re: [Zope] How to make a script return rendered dtml


> Try this:
>
> (!! be careful with excessive recurssion !!)
>
> print context.index_html(context,ERQUEST)

OK, I tried that and got a name error on REQUEST, so I did this instead:

print context.index_html(context, context.REQUEST)

But that gave me an error like:

Error Type: TypeError
Error Value: no arguments expected

So I tried not supplying any arguments... context.index_html(), and got the
'excessive recursion error'.

Any clues?

Thanks

tim



> ----- Original Message -----
> From: "Tim Hicks" <tim@sitefusion.co.uk>
> To: <zope@zope.org>
> Sent: Wednesday, June 13, 2001 3:39 PM
> Subject: [Zope] How to make a script return rendered dtml
>
>
> > 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,
> >
> > &lt;dtml-var standard_html_header&gt;
> >
> > 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 )
>