Commit adef573c authored by Arnaud Fontaine's avatar Arnaud Fontaine

No need to bind lastRequestPystones as everything is in seconds now and can be

later converted to pystones by calling browser.timer.pystonesPerSecond() on a
Browser instance.

With the previous commit, it allows to have shorter and nicer method names.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@46002 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b7e22773
......@@ -50,8 +50,8 @@ def measurementMetaClass(prefix):
class MeasurementMetaClass(type):
"""
Meta class to automatically wrap methods whose prefix starts with
C{prefix}, and also to define C{lastRequestSeconds} and
C{lastRequestPystones} on other classes besides of Browser.
C{prefix}, and also to define C{lastRequestSeconds} on other classes
besides of Browser.
"""
def __new__(metacls, name, bases, dictionary):
def timeInSecondDecorator(method):
......@@ -92,20 +92,15 @@ def measurementMetaClass(prefix):
if callable(attribute):
applyMeasure(attribute)
# lastRequestSeconds and lastRequestPystones properties are only
# defined on classes inheriting from zope.testbrowser.browser.Browser,
# so create these properties for all other classes too
# lastRequestSeconds properties are only defined on classes inheriting
# from zope.testbrowser.browser.Browser, so create these properties for
# all other classes too
if 'Browser' not in bases[0].__name__:
time_method = lambda self: self.browser.lastRequestSeconds
time_method.func_name = 'lastRequestSeconds'
time_method.__doc__ = Browser.lastRequestSeconds.__doc__
dictionary['lastRequestSeconds'] = property(time_method)
time_method = lambda self: self.browser.lastRequestPystones
time_method.func_name = 'lastRequestPystones'
time_method.__doc__ = Browser.lastRequestPystones.__doc__
dictionary['lastRequestPystones'] = property(time_method)
return super(MeasurementMetaClass,
metacls).__new__(metacls, name, bases, dictionary)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment