| 58 | | templ = self._templatecache.get(template, None) |
|---|
| 59 | | if not templ: |
|---|
| 60 | | templ = kid.import_template(name=template) |
|---|
| 61 | | self._templatecache[template] = templ |
|---|
| 62 | | t = templ.Template(**cherrypy.response.body) |
|---|
| 63 | | t.assume_encoding=assume_encoding |
|---|
| 64 | | cherrypy.response.body = t.serialize(output=output, encoding=encoding) |
|---|
| 65 | | if output is None or 'xhtml' in output: |
|---|
| 66 | | if 'application/xhtml+xml' in cherrypy.request.headers['Accept']: |
|---|
| 67 | | cherrypy.response.headers['Content-Type'] = 'application/xhtml+xml' |
|---|
| 68 | | else: |
|---|
| 69 | | #This is nasty, but such is the state of XHTML today |
|---|
| 70 | | cherrypy.response.headers['Content-Type'] = 'text/html; charset=%s' % encoding |
|---|
| | 58 | cherrypy.request._handler = cherrypy.request.handler |
|---|
| | 59 | def wrap(*args, **kwargs): |
|---|
| | 60 | ret = cherrypy.request._handler(*args, **kwargs) |
|---|
| | 61 | templ = self._templatecache.get(template, None) |
|---|
| | 62 | if not templ: |
|---|
| | 63 | templ = kid.import_template(name=template) |
|---|
| | 64 | self._templatecache[template] = templ |
|---|
| | 65 | t = templ.Template(**ret) |
|---|
| | 66 | t.assume_encoding=assume_encoding |
|---|
| | 67 | out = t.serialize(output=output, encoding=encoding) |
|---|
| | 68 | if output is None or 'xhtml' in output: |
|---|
| | 69 | if 'application/xhtml+xml' in cherrypy.request.headers['Accept']: |
|---|
| | 70 | cherrypy.response.headers['Content-Type'] = 'application/xhtml+xml' |
|---|
| | 71 | else: |
|---|
| | 72 | #This is nasty, but such is the state of XHTML today |
|---|
| | 73 | cherrypy.response.headers['Content-Type'] = 'text/html; charset=%s' % encoding |
|---|
| | 74 | return out |
|---|