kron kron4eg hg byteflow apps lib hg diff diff -r d4cba6c28b88 apps li

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
kron@kron4eg:~/hg/byteflow/apps/lib$ hg diff
diff -r d4cba6c28b88 apps/lib/decorators.py
--- a/apps/lib/decorators.py Sun Feb 17 00:44:23 2008 +0200
+++ b/apps/lib/decorators.py Wed Feb 20 22:08:16 2008 +0200
@@ -1,6 +1,6 @@ from lib.http import JsonResponse, rende
from lib.http import JsonResponse, render_response
-def render_to(tmpl):
+def render_to(fallback_tmpl, template_key_name=None):
"""
Decorator for Django views that sends returned dict to render_to_response function
with given template and RequestContext as context instance.
@@ -12,6 +12,7 @@ def render_to(tmpl):
output = func(request, *args, **kw)
if not isinstance(output, dict):
return output
+ tmpl = output.get(template_key_name, fallback_tmpl)
return render_response(request, tmpl, output)
return wrapper
return renderer