|
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 $ |
2 | 2 |
|
3 | 3 | """WWW request handler (also used in the stand-alone server). |
4 | 4 | """ |
@@ -658,14 +658,21 @@ def renderContext(self): |
658 | 658 | # let the template render figure stuff out |
659 | 659 | result = pt.render(self, None, None, **args) |
660 | 660 | 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 |
663 | 669 | 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 |
669 | 676 | s += '</body>' |
670 | 677 | result = result.replace('</body>', s) |
671 | 678 | return result |
|
0 commit comments