[Zope] Saving a rendered DTML document with LocalFS

Pavlos Christoforou pavlos@gaaros.com
Wed, 10 May 2000 14:24:51 -0400 (EDT)


On Wed, 10 May 2000, Steve Alexander wrote:

> Jim Sanford wrote:
> > 
> > Any suggestions on an easy way to save a rendedred DTML document to a file with LocalFS?
> > 
> > We have a DTML document that is a report that can be rendered on command showing the current status of orders. We send out a daily
> > summary to an email list. The summary has a link to the archived detail report. Currently the detail report is brought up in the
> > browser and we do a "Save as.." to save the renderd copy.
> > 
> > I would like to automate the saving of the rendered copy.
> > 
> > Any suggestions?
> 
> Use something like this:
> 
>   <dtml-let rendered_data="_.render(your_dtml_method)">
>       Code to save rendered_data into file using LocalFS here
>   </dtml-let>
> 

If all you need is to save it on the filesystem just write an external
method that does that. Something like <untested>

def save(self,doc,filepath):
    try:
     open(filepath,'w').write(doc)
    except:
     return 0
    return 1

and call it from your DTML method like

<dtml-call "save(_.render(<the report method>),'/tmp/report.doc'))">

Pavlos