view pylons_app/lib/timerproxy.py @ 74:cdf4fda66dd9

Started summary page. Added filters to templates. used by n,self.f.filtername prefixed by n to disable other filters. Few other fixes found
author Marcin Kuzminski <marcin@python-blog.com>
date Mon, 12 Apr 2010 10:29:18 +0200
parents 3ada2f409c1c
children 0c22a870bb79
line wrap: on
line source

from sqlalchemy.interfaces import ConnectionProxy
import time
import logging
log = logging.getLogger(__name__)

class TimerProxy(ConnectionProxy):
    def cursor_execute(self, execute, cursor, statement, parameters, context, executemany):
        now = time.time()
        try:
            log.info(">>>>> STARTING QUERY >>>>>")
            return execute(cursor, statement, parameters, context)
        finally:
            total = time.time() - now
            log.info("Query: %s" % statement % parameters)
            log.info("<<<<< TOTAL TIME: %f <<<<<" % total)