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 #1923 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

Custom content type

Reported by: matiu Owned by: splee
Priority: normal Milestone:
Component: TurboGears Version: trunk
Severity: normal Keywords:


This patch solves two problems:

  1. It lets you go:
import pylons
from tg.controllers import CUSTOM_CONTENT_TYPE

    def someCustomMethod(self):
        pylons.response.headers['content-type'] = lookupSomeDynamicContentType() # eg. 'image/png'
  1. The changes to decorators.py stop tg from adding 'charset=utf-8' on the end of non-text content types. Eg. content-type: image/png; charset=utf-8' is pretty stink..


content_type.diff Download (3.0 KB) - added by matiu 11 years ago.

Change History

Changed 11 years ago by matiu

comment:1 Changed 11 years ago by matiu

To be more specific, setting: @expose(content_type=CUSTOM_CONTENT_TYPE) stops turbogears from overriding whatever content-type you set in the pylons response; although if the content-type is text/something, with no charset, tg2 will add a charset=utf-8.

comment:2 Changed 11 years ago by splee

  • Status changed from new to assigned
  • Owner changed from anonymous to splee

comment:3 Changed 11 years ago by mramm

  • Milestone changed from 2.0-preview-2 to 2.0-preview-3

comment:4 Changed 11 years ago by splee

  • Status changed from assigned to closed
  • Resolution set to fixed

Applied in r5146

comment:5 Changed 11 years ago by anonymous

  • Milestone 1.9.7a4 deleted

Milestone 1.9.7a4 deleted

comment:6 Changed 10 years ago by jorge.vargas

FYI, this was a horrible implementation see #2158 for a proper fix.

Note: See TracTickets for help on using tickets.