From 8e5fcbccae6e2b774d96fa7c2db59b5edaabf40e Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Fri, 26 May 2006 19:29:22 +0000 Subject: Added a way of overriding where the prints get outputed to --- paste/debug/prints.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'paste/debug') diff --git a/paste/debug/prints.py b/paste/debug/prints.py index c2cfaa6..795ef73 100644 --- a/paste/debug/prints.py +++ b/paste/debug/prints.py @@ -3,6 +3,18 @@ """ Middleware that displays everything that is printed inline in application pages. + +Anything printed during the request will get captured and included on +the page. It will usually be included as a floating element in the +top right hand corner of the page. If you want to override this +you can include a tag in your template where it will be placed:: + +

+
+You might want to include ``style="white-space: normal"``, as all the
+whitespace will be quoted, and this allows the text to wrap if
+necessary.
+
 """
 
 from cStringIO import StringIO
@@ -105,15 +117,19 @@ class PrintDebugMiddleware(object):
             threadedprint.deregister()
 
     _body_re = re.compile(r']*>', re.I)
-        
+    _explicit_re = re.compile(r']*id="paste.debug.prints".*?>',
+                              re.I+re.S)
+    
     def add_log(self, html, log):
         if not log:
             return html
         text = cgi.escape(log)
         text = text.replace('\n', '
\n') text = text.replace(' ', '  ') - log = self.log_template % text - match = self._body_re.search(html) + match = self._explicit_re.search(html) + if not match: + log = self.log_template % log + match = self._body_re.search(html) if not match: return log + html else: -- cgit v1.2.1