diff -r 6346f53c85f1 -r 0aebb1c0f849 utils.py
--- a/utils.py Wed Nov 19 11:57:55 2014 +0100
+++ b/utils.py Wed Nov 19 12:13:32 2014 +0100
@@ -206,12 +206,23 @@
specifed in the constructor
"""
+ def __init__(self, tracewrites=False, *args, **kwargs):
+ self.tracewrites = tracewrites
+ super(UStringIO, self).__init__(*args, **kwargs)
+
def __nonzero__(self):
return True
def write(self, value):
assert isinstance(value, unicode), u"unicode required not %s : %s"\
% (type(value).__name__, repr(value))
+ if self.tracewrites:
+ from traceback import format_stack
+ stack = format_stack(None)[:-1]
+ escaped_stack = xml_escape(json_dumps(u'\n'.join(stack)))
+ escaped_html = xml_escape(value).replace('\n', '
\n')
+ tpl = u'%s'
+ value = tpl % (escaped_stack, escaped_html)
self.append(value)
def getvalue(self):
@@ -234,8 +245,8 @@
script_opening = u''
- def __init__(self, req):
- super(HTMLHead, self).__init__()
+ def __init__(self, req, *args, **kwargs):
+ super(HTMLHead, self).__init__(*args, **kwargs)
self.jsvars = []
self.jsfiles = []
self.cssfiles = []
@@ -399,10 +410,15 @@
w(self.script_opening)
w(u'\n\n'.join(self.post_inlined_scripts))
w(self.script_closing)
- header = super(HTMLHead, self).getvalue()
- if skiphead:
- return header
- return u'