I have been battling this problem and I finally figured out what is
going on.

I have a method in my controller which returns some automatically
generated csv data, like this:

 @expose()
 def export(self,  **kw):
        r = 'asdf,asdf,asdf'
        response = pylons.response
        response.headers['content-type'] = "application/csv"
        response.headers['Content-Transfer-Encoding'] = 'Binary'
        response.headers['Content-length'] = len(r)
        response.headers['Content-Disposition'] = 'attachment;
filename=\"mygenerated.csv\"'
        response.headers['Connection'] = "close"
        return r

The problem is that when the response is sent back to the server, the
content-type returns to 'text/html' which causes Safari to add an
extra ".html" to the file when it downloads:

#the header response from the server
Server  PasteWSGIServer/0.5 Python/2.5.1
Date    Wed, 07 May 2008 15:59:25 GMT
Pragma  no-cache
Cache-Control   no-cache
Content-Transfer-Encoding       Binary
content-disposition     attachment; filename="mygenerated.csv"
Connection      close
Content-Type    text/html; charset=utf-8
Content-Length  14



  This is not desirable.  Perhaps we need to  define what the content
type is and pass that to the expose decorator?  Why won't my header
setting "stick"?

cheers.
-chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to