johnnyice wrote:
> James Gardner already posted how to set the content type when using
> the render object in the forum.
>
> response.headers['Content-type'] = "application/atom+xml"
> return render("template_file", "atom-feed")
>
> src:
> http://groups.google.com/group/pylons-discuss/browse_thread/thread/2e0a6cb533ddd0a6/e2ce72d10277fe99?lnk=gst&q=content+type+xml#e2ce72d10277fe99http://groups.google.com/group/pylons-discuss/browse_thread/thread/2e0a6cb533ddd0a6/e2ce72d10277fe99?lnk=gst&q=content+type+xml#e2ce72d10277fe99
>
>
> BUT, how would you go about setting the content type for a Response
> object?
>
> This worked in 0.9.5, but does not work in 0.9.6.1
>
> xml = '<result>Something</result>'
> response = Response(xml)
> response.headers['content-type'] = 'text/xml; charset=utf-8'
> return response
>
>
> Any ideas?
Don't use Response object. Use response as James Garner offers. Your
code should be written in this way:
xml = '<result>Something</result>'
response.headers['Content-type'] = 'text/xml; charset=utf-8'
return xml
Usually you should return string from controller (I think the only
exception is @jsonify - you can return dict there). BTW, if you want to
serve images this way it will be very slow. There are better ways to do
that.
Regards,
Dalius
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---