I have the following Python script which allows the user to download an XML file generated by the DTML method 'controlmakeXML'. I want to be able to generate the filename (fname) on the fly from the request but I'm having a problem with the syntax to insert the variable as filename=fname in the script. Can anyone help, it's probably a very simple thing that I am missing! request = container.REQUEST RESPONSE = request.RESPONSE fname=request.me data = context.controlmakeXML RESPONSE.setHeader('Content-Type', 'application/download') RESPONSE.setHeader('Content-Length', len(data)) RESPONSE.setHeader('Content-Disposition','attachment;filename=fname') return data reagards garry
garry saddington wrote:
I have the following Python script which allows the user to download an XML file generated by the DTML method 'controlmakeXML'. I want to be able to generate the filename (fname) on the fly from the request but I'm having a problem with the syntax to insert the variable as filename=fname in the script. Can anyone help, it's probably a very simple thing that I am missing!
RESPONSE.setHeader('Content-Disposition','attachment;filename=fname')
How about: RESPONSE.setHeader('Content-Disposition','attachment;filename=%s' % (fname)) HTH, JZ
On Wednesday 22 December 2004 21:03, John Ziniti wrote:
garry saddington wrote:
I have the following Python script which allows the user to download an XML file generated by the DTML method 'controlmakeXML'. I want to be able to generate the filename (fname) on the fly from the request but I'm having a problem with the syntax to insert the variable as filename=fname in the script. Can anyone help, it's probably a very simple thing that I am missing!
RESPONSE.setHeader('Content-Disposition','attachment;filename=fname')
How about:
RESPONSE.setHeader('Content-Disposition','attachment;filename=%s' % (fname)) Thanks that worked, was just onto trying this but had the ' in the wrong place! regards garry HTH, JZ
participants (2)
-
garry saddington -
John Ziniti