straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

ragendja.template.render_to_response syntax error for xhtml #169

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In ragendja.template.render_to_response, the variable "response" is used
without being declared. It only occurs when the content type is
application/xhtml+xml. This special case occurs because IE can't handle
application/xhtml+xml.

It's currently present in the head revision.

On my local copy, I made it middleware instead:

class XHtmlMiddleware(object):
    """Middleware that fixes IE XHTML problems."""

    def process_response(self, request, response):
        content_type = response['Content-Type'].split(';', 1)
        if content_type:
            content_type = content_type[0]
        assert(isinstance(content_type, basestring))
        if content_type == 'application/xhtml+xml':
            if request.META.get('HTTP_ACCEPT').find(content_type) == -1:
                content_type = 'text/html; charset=%s' % settings.DEFAULT_CHARSET
                response['Content-Type'] = content_type
            from django.utils.cache import patch_vary_headers
            patch_vary_headers(response, ['User-Agent'])
        return response

Not perfect, but you get the idea.

Original issue reported on code.google.com by NagelBa...@gmail.com on 22 Jun 2009 at 4:57

GoogleCodeExporter commented 9 years ago
Please test again with the repo version.

Original comment by wkornew...@gmail.com on 22 Jun 2009 at 9:33

GoogleCodeExporter commented 9 years ago
Any news?

Original comment by wkornew...@gmail.com on 24 Jun 2009 at 5:24

GoogleCodeExporter commented 9 years ago
OK, verified this with a few tests.

Original comment by wkornew...@gmail.com on 28 Jun 2009 at 1:47