Changeset 1585 for trunk/pylucid/PyLucid/middlewares/pagestats.py
- Timestamp:
- 05/23/08 16:33:49 (6 months ago)
- Files:
-
- 1 modified
-
trunk/pylucid/PyLucid/middlewares/pagestats.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pylucid/PyLucid/middlewares/pagestats.py
r1546 r1585 25 25 26 26 from PyLucid.template_addons.filters import human_duration 27 from PyLucid.middlewares.utils import is_html, replace_content 27 28 28 29 # Save the start time of the current running pyhon instance … … 51 52 """ 52 53 # Put only the statistic into HTML pages 53 if not "html" in response._headers["content-type"][1]:54 if not is_html(response): 54 55 # No HTML Page -> do nothing 55 56 return response … … 69 70 } 70 71 71 content = response.content 72 if not isinstance(content, unicode): 73 # FIXME: In my shared webhosting environment is response.content a 74 # string and not unicode. Why? 75 from django.utils.encoding import force_unicode 76 try: 77 content = force_unicode(content) 78 except: 79 return response 72 # insert the page statistic 73 response = replace_content(response, TAG, stat_info) 80 74 81 # content = self.debug_sql_queries(content) 82 83 # insert the page statistic 84 new_content = content.replace(TAG, stat_info) 85 response.content = new_content 75 #response = self.debug_sql_queries(response) 86 76 87 77 return response 88 78 89 def debug_sql_queries(self, content): 79 def debug_sql_queries(self, response): 80 """ 81 Insert all SQL queries. 82 ONLY for developers! 83 """ 90 84 show_only = ("PyLucid_plugin", "PyLucid_preference2") 91 85 sql_info = "<h2>Debug SQL queries:</h2>" … … 106 100 sql_info += "\n%s\n%s\n" % (time, sql) 107 101 sql_info += "</pre></body>" 108 content = content.replace("</body>", sql_info) 109 return content 102 103 response = replace_content(response, "</body>", sql_info) 104 105 return response
