Calling DTML Document from python script
I got an object 'file' witch contains a DTML Document object. When I try to call it from a pythton script like this : print file() I get the error : Error Type: KeyError Error Value: standard_html_header So what I need to do is to print out the DTML document without it's header and footer (<dtml-var standard_html_header> and <dtml-var standard_html_footer>) and still that it's content get executed (all other dtml-var gets resolved) Anyone knows how to do that and maybe what parameter I have to pass to the print file(...) function?
On Tue, Sep 18, 2001 at 09:51:00AM -0400, Laurent Duchesne wrote:
I got an object 'file' witch contains a DTML Document object. When I try to call it from a pythton script like this : print file() I get the error : Error Type: KeyError Error Value: standard_html_header
Every DTML object requires context and REQUEST, so try something like this: print file(context, context.REQUEST) Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
You got the problem right and I thank you for that. Now the only thing is that it also print out the header and the footer so it looks a little crazy ;) The way I see it, I could read the data, remove the header/footer tag with regular expression, write to a temp DTML document and print it. Is there a better way to do that? Laurent Le Mardi 18 Septembre 2001 09:55, Oleg Broytmann a écrit :
On Tue, Sep 18, 2001 at 09:51:00AM -0400, Laurent Duchesne wrote:
I got an object 'file' witch contains a DTML Document object. When I try to call it from a pythton script like this : print file() I get the error : Error Type: KeyError Error Value: standard_html_header
Every DTML object requires context and REQUEST, so try something like this: print file(context, context.REQUEST)
Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
_______________________________________________ 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 )
On Tue, Sep 18, 2001 at 10:06:53AM -0400, Laurent Duchesne wrote:
You got the problem right and I thank you for that. Now the only thing is that it also print out the header and the footer so it looks a little crazy ;) The way I see it, I could read the data, remove the header/footer tag with regular expression, write to a temp DTML document and print it.
Is there a better way to do that?
Recreate yor file: make an object without header/footer (let's name it raw_file) and an object that includes header, raw_file, and footer. Put the "file" on the Web, but print only raw_file. Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
2 possible ways: (a) use redirect or (b) return the DTML doc as object (a) context.REQUEST.RESPONSE.redirect(uri_of_your_dtml_document) return (b) return context.restrictedTraverse(uri_of_your_dtml_document) ----- Original Message ----- From: "Laurent Duchesne" <laurent@levinux.org> To: <zope@zope.org> Sent: Tuesday, September 18, 2001 3:51 PM Subject: [Zope] Calling DTML Document from python script
I got an object 'file' witch contains a DTML Document object. When I try to call it from a pythton script like this : print file() I get the error : Error Type: KeyError Error Value: standard_html_header
So what I need to do is to print out the DTML document without it's header and footer (<dtml-var standard_html_header> and <dtml-var standard_html_footer>) and still that it's content get executed (all other dtml-var gets resolved)
Anyone knows how to do that and maybe what parameter I have to pass to the print file(...) function?
_______________________________________________ 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 )
participants (3)
-
Gilles Lenfant -
Laurent Duchesne -
Oleg Broytmann