diff roundup/cgi/client.py @ 2942:a50e4f7c9276

look for CGI_SHOW_TIMING in self.env instead of os.environ; implemented hidden timings (in html comment)
author Alexander Smishlajev <a1s@users.sourceforge.net>
date Mon, 22 Nov 2004 07:10:24 +0000
parents 00f609d53a8c
children 661028d24cd2
line wrap: on
line diff
--- a/roundup/cgi/client.py	Sun Nov 21 21:55:03 2004 +0000
+++ b/roundup/cgi/client.py	Mon Nov 22 07:10:24 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: client.py,v 1.205 2004-11-21 21:55:03 richard Exp $
+# $Id: client.py,v 1.206 2004-11-22 07:10:24 a1s Exp $
 
 """WWW request handler (also used in the stand-alone server).
 """
@@ -658,14 +658,21 @@
             # let the template render figure stuff out
             result = pt.render(self, None, None, **args)
             self.additional_headers['Content-Type'] = pt.content_type
-            if os.environ.get('CGI_SHOW_TIMING', ''):
-                s = '<p>Time elapsed: %fs</p>'%(time.time()-self.start)
+            if self.env.get('CGI_SHOW_TIMING', ''):
+                if self.env['CGI_SHOW_TIMING'].upper() == 'COMMENT':
+                    timings = {'starttag': '<!-- ', 'endtag': ' -->'}
+                else:
+                    timings = {'starttag': '<p>', 'endtag': '</p>'}
+                timings['seconds'] = time.time()-self.start
+                s = self._('%(starttag)sTime elapsed: %(seconds)fs%(endtag)s\n'
+                    ) % timings
                 if hasattr(self.db, 'stats'):
-                    s += '''<p>Cache hits: %(cache_hits)d,
-                        misses %(cache_misses)d.
-                        Loading items: %(get_items)f secs.
-                        Filtering: %(filtering)f secs.
-                        </p>'''%self.db.stats
+                    timings.update(self.db.stats)
+                    s += self._("%(starttag)sCache hits: %(cache_hits)d,"
+                        " misses %(cache_misses)d."
+                        " Loading items: %(get_items)f secs."
+                        " Filtering: %(filtering)f secs."
+                        "%(endtag)s\n") % timings
                 s += '</body>'
                 result = result.replace('</body>', s)
             return result

Roundup Issue Tracker: http://roundup-tracker.org/