Page not reloading

1 message Options
Embed this post
Permalink
rmplone () Page not reloading
Reply Threaded More More options
Print post
Permalink
I'm running Zope 2.9.8 and Plone 2.5.3.

The user generates text and I display it in a page along with buttons to "save to file" or "quit". I'm using page templates and the form controller so when the user presses the "save to file" button, it is routed via the metadata file to this controller python script:

=======================
## Script (Python) "zzsave_mangather_to_file"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=gather_body_text, save_complete
##title=Save manual gather data to file
##

from DateTime import DateTime

request = container.REQUEST
RESPONSE =  request.RESPONSE

filename = "9904457.F01."
mydate = '%s' % ( DateTime().strftime('%m%d%H%M%S') )
filename = filename + mydate

RESPONSE.setHeader("Content-type","text/download")
RESPONSE.setHeader("Content-length",len(gather_body_text))
RESPONSE.setHeader("Content-disposition","attachment;filename=%s" %(filename))
RESPONSE.write(gather_body_text)

request.set('save_complete', 'Y')

return state
======================
The text is in the gather_body_text and the user is prompted to save the file. That works fine. I then want to reroute it back to the page with the text and buttons on the reload of this page. I want to check with the user to see if the text file was saved properly before I change things behind the scenes in the database. I route it after the above script is run using the metadata file entry:

action.success=traverse_to:string:zzpt_gather_manual

The problems is that the page never reloads, so I can't trigger the code to prompt the user on load. If I comment out the following lines in the above script:

RESPONSE.setHeader("Content-disposition","attachment;filename=%s" %(filename))
RESPONSE.write(gather_body_text)

the page reloads. But of course the user no longer can save the file. The controller does get to
the action.success line above. I've checked that out. But appears setting the response headers is messing up the form controller. Any ideas?

Thanks in advance,
Bob