Commit 600b81fb authored by Vincent Pelletier's avatar Vincent Pelletier

Make it easy to disable attribute tracker to remove its runtime overhead.

Keep it enabled by default so tests run with it.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1667 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 397410c9
......@@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
ATTRIBUTE_TRACKER_ENABLED = True
from neo.locking import LockUser
"""
......@@ -43,11 +45,15 @@ def tracker_setattr(self, attr, value, setattr):
modification_container[attr] = LockUser()
setattr(self, attr, value)
def track(klass):
original_setattr = klass.__setattr__
def klass_tracker_setattr(self, attr, value):
tracker_setattr(self, attr, value, original_setattr)
klass.__setattr__ = klass_tracker_setattr
if ATTRIBUTE_TRACKER_ENABLED:
def track(klass):
original_setattr = klass.__setattr__
def klass_tracker_setattr(self, attr, value):
tracker_setattr(self, attr, value, original_setattr)
klass.__setattr__ = klass_tracker_setattr
else:
def track(klass):
pass
def whoSet(instance, attr):
result = getattr(instance, MODIFICATION_CONTAINER_ID, None)
......
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