Skip to content

Commit 049c675

Browse files
author
Alexander Smishlajev
committed
look for CGI_SHOW_TIMING in self.env instead of os.environ;
implemented hidden timings (in html comment)
1 parent 30727c4 commit 049c675

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

roundup/cgi/client.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.205 2004-11-21 21:55:03 richard Exp $
1+
# $Id: client.py,v 1.206 2004-11-22 07:10:24 a1s Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -658,14 +658,21 @@ def renderContext(self):
658658
# let the template render figure stuff out
659659
result = pt.render(self, None, None, **args)
660660
self.additional_headers['Content-Type'] = pt.content_type
661-
if os.environ.get('CGI_SHOW_TIMING', ''):
662-
s = '<p>Time elapsed: %fs</p>'%(time.time()-self.start)
661+
if self.env.get('CGI_SHOW_TIMING', ''):
662+
if self.env['CGI_SHOW_TIMING'].upper() == 'COMMENT':
663+
timings = {'starttag': '<!-- ', 'endtag': ' -->'}
664+
else:
665+
timings = {'starttag': '<p>', 'endtag': '</p>'}
666+
timings['seconds'] = time.time()-self.start
667+
s = self._('%(starttag)sTime elapsed: %(seconds)fs%(endtag)s\n'
668+
) % timings
663669
if hasattr(self.db, 'stats'):
664-
s += '''<p>Cache hits: %(cache_hits)d,
665-
misses %(cache_misses)d.
666-
Loading items: %(get_items)f secs.
667-
Filtering: %(filtering)f secs.
668-
</p>'''%self.db.stats
670+
timings.update(self.db.stats)
671+
s += self._("%(starttag)sCache hits: %(cache_hits)d,"
672+
" misses %(cache_misses)d."
673+
" Loading items: %(get_items)f secs."
674+
" Filtering: %(filtering)f secs."
675+
"%(endtag)s\n") % timings
669676
s += '</body>'
670677
result = result.replace('</body>', s)
671678
return result

0 commit comments

Comments
 (0)