Bug #270
@templating.page will always change the content type
| Status: | New | Start: | 2008-12-18 | |
| Priority: | Normal | Due date: | ||
| Assigned to: | - | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - | |||
Description
@template.page defaults the content type to 'text/html; charset=utf-8'. That will break the following code:
@resource.GET(accept='xhtml')
@templating.page('template.html')
def xhtml(self, request):
return {}
i.e the xhtml() method will be called for "Accept: application/xhtml+xml" requests but will return a "Content-Type: text/html; charset=utf-8" response!
Not entirely sure what to do about this right now but I think the "best match" calculated in Resource.__call__ needs to be calculated earlier and left as a hint on the environ for page.templating to pick up and use, combining it with charset=utf-8. Of course, if the environ hint is ignored Resource.__call__ is ok to set the content type automatically, as it currently does.
/me wonders if this sort of behaviour really belongs to page.Page rather than resource.Resource. Something to think about more when it's time to fix this issue.