示例#1
0
    def process_response(self, request, response):
        """
        calculate the statistic and replace it into the html page.
        """
        # Put only the statistic into HTML pages
        if not is_html(response):
            # No HTML Page -> do nothing
            return response

        context = {
            'total_time' : human_duration(time() - self.start_time),
            'overall_time' : human_duration(time() - start_overall),
        }

        if settings.DEBUG:
            # compute the db time for the queries just run, this information is
            # only available if the debug cursor used
            context["queries"] = len(connection.queries) - self.old_queries
            stat_info = FMT_DEBUG % context
        else:
            # Used the template without queries
            stat_info = FMT % context

        # insert the page statistic
        response = replace_content(response, TAG, stat_info)

        #response = self.debug_sql_queries(response)

        return response
    def process_response(self, request, response):
        """
        insert all page messages into the html page.
        """
        if not is_html(response):
            # No HTML Page -> do nothing
            return response

        try:
            # get PyLucid.system.page_msg.PageMessages():
            page_msg = request.page_msg
        except AttributeError, e:
            message_string = "Error getting page_msg: %s" % e