summaryrefslogtreecommitdiff
path: root/paste
diff options
context:
space:
mode:
authorianb <devnull@localhost>2007-03-06 01:07:44 +0000
committerianb <devnull@localhost>2007-03-06 01:07:44 +0000
commitf1f3cc7cd9ca003c4920825b8ad2521a43c02f4c (patch)
tree9021fdb6020a816f59109c8d11073d0d14d09392 /paste
parenta2bd62dd31636b4842e25458e1cbbea3a3052467 (diff)
downloadpaste-f1f3cc7cd9ca003c4920825b8ad2521a43c02f4c.tar.gz
in template: Added a function that can be used with Paste Script; fixed an issue when you raise Exception()
Diffstat (limited to 'paste')
-rw-r--r--paste/util/template.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/paste/util/template.py b/paste/util/template.py
index d76f6b3..4da60c8 100644
--- a/paste/util/template.py
+++ b/paste/util/template.py
@@ -192,7 +192,11 @@ class Template(object):
except:
exc_info = sys.exc_info()
e = exc_info[1]
- e.args = (self._add_line_info(e.args[0], pos),)
+ if getattr(e, 'args'):
+ arg0 = e.args[0]
+ else:
+ arg0 = str(e)
+ e.args = (self._add_line_info(arg0, pos),)
raise exc_info[0], e, exc_info[2]
def _exec(self, code, ns, pos):
@@ -251,6 +255,10 @@ def sub(content, **kw):
return tmpl.substitute(kw)
return result
+def paste_script_template_renderer(content, vars, filename=None):
+ tmpl = Template(content, name=filename)
+ return tmpl.substitute(vars)
+
class bunch(dict):
def __init__(self, **kw):