diff options
author | Mark McClain <mark.mcclain@shootq.com> | 2011-01-27 13:21:38 -0500 |
---|---|---|
committer | Mark McClain <mark.mcclain@shootq.com> | 2011-01-27 13:21:38 -0500 |
commit | f8f437d953834e4167b62b29fa49e151cd795834 (patch) | |
tree | 017a440b1f0fe12b3ebfb10aa1a789f8e244c854 /pecan/core.py | |
parent | d6e20d6f204b27e578900ff96b4a0efb0e04380c (diff) | |
download | pecan-f8f437d953834e4167b62b29fa49e151cd795834.tar.gz |
adding ability to change content type when overriding template
Diffstat (limited to 'pecan/core.py')
-rw-r--r-- | pecan/core.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pecan/core.py b/pecan/core.py index 1f0f5a0..56b99dd 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -41,8 +41,10 @@ request = proxy('request') response = proxy('response') -def override_template(template): +def override_template(template, content_type=None): request.override_template = template + if content_type: + request.override_content_type = content_type def abort(status_code=None, detail='', headers=None, comment=None): raise exc.status_map[status_code](detail=detail, headers=headers, comment=comment) @@ -290,7 +292,10 @@ class Pecan(object): # pull the template out based upon content type and handle overrides template = cfg.get('content_types', {}).get(state.content_type) + + # check if for controller override of template template = getattr(request, 'override_template', template) + state.content_type = getattr(request, 'override_content_type', state.content_type) # if there is a template, render it if template: |