Ticket #1971 (closed enhancement: migrated)
Improve determination of content type in view.base.render
| Reported by: | Chris Arndt | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.1.x bugfix |
| Component: | TurboGears | Version: | 1.0.6 |
| Severity: | normal | Keywords: | rendering, view, content type |
| Cc: |
Description
In view.base.render the content type in the response headers is determined by looking at the output format. A source code comment says:
# We simply derive the content type from the format here # and use the charset specified in the configuration setting. # This could be improved by also examining the engine and the output.
A better solution would also handle the cases where format is XTMLSerializer, XMLSerializer or PlainSerializer instance and derive the proper content type.
Solution 1: TurboKid (and other engines) could provide an auxiliary function for deriving a proper content type from the format parameter. (TurboJson had a similar function for deriving the content type from the user agent, but this is not used any more).
Solution 2: Or, this auxiliary function could be put into tg.util. We already have a similar function get_template_encoding_default(enginename) there.
See also #1878.
Change History
comment:1 Changed 5 years ago by Chris Arndt
- Keywords rendering, view, content type added
- Summary changed from Improve detrmination of content type in view.base.render to Improve determination of content type in view.base.render