Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2263 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Custom Content Type document needs to be fixed.

Reported by: AZMel Owned by:
Priority: normal Milestone: 2.1a1
Component: Documentation Version: 2.0b7
Severity: normal Keywords:


The document at  http://turbogears.org/2.0/docs/main/ResponseTypes.html shows

import pylons
from tg.controllers import CUSTOM_CONTENT_TYPE

class MyController:
    def stats(self):
        pylons.request['Content-Type'] = 'text/csv'
        pylons.request['Content-Disposition'] = 'attachment;filename=stats.csv'
        return '1,2,3'

In the Custom Content Type section:

        pylons.request['Content-Type'] = 'text/csv'
        pylons.request['Content-Disposition'] = 'attachment;filename=stats.csv'

should be replaced with:

        pylons.response.headers['Content-Type'] = 'text/csv'
        pylons.response.headers['Content-Disposition'] = 'attachment;filename=stats.csv'

and possibly a note that 'text/csv' may need to be 'text/csv; charset=utf-8' for unicode.

Change History

comment:1 Changed 10 years ago by mramm

  • Milestone changed from 2.0rc1 to 2.0rc2

comment:2 Changed 10 years ago by percious

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.