Add the conflict resolver for id tool


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34600 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 77a7a3af
...@@ -34,6 +34,7 @@ import string ...@@ -34,6 +34,7 @@ import string
import time import time
import warnings import warnings
import sys import sys
import persistent
try: try:
# Python 2.5 or later # Python 2.5 or later
from hashlib import md5 as md5_new from hashlib import md5 as md5_new
...@@ -70,7 +71,7 @@ from Products.ERP5Type.Accessor.Constant import PropertyGetter as \ ...@@ -70,7 +71,7 @@ from Products.ERP5Type.Accessor.Constant import PropertyGetter as \
from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter
from Products.ERP5Type.Cache import getReadOnlyTransactionCache from Products.ERP5Type.Cache import getReadOnlyTransactionCache
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from zLOG import LOG, BLATHER, PROBLEM, WARNING from zLOG import LOG, BLATHER, PROBLEM, WARNING, INFO
##################################################### #####################################################
# Avoid importing from (possibly unpatched) Globals # Avoid importing from (possibly unpatched) Globals
...@@ -3125,3 +3126,33 @@ def _setSuperSecurityManager(self, user_name=None): ...@@ -3125,3 +3126,33 @@ def _setSuperSecurityManager(self, user_name=None):
user = self.getWrappedOwner() user = self.getWrappedOwner()
newSecurityManager(self.REQUEST, user) newSecurityManager(self.REQUEST, user)
return original_security_manager return original_security_manager
#####################################################
# Processing of Conflict Resolver
#####################################################
class ScalarMaxConflictResolver(persistent.Persistent):
"""
Store the last id generated
The object support application-level conflict resolution
"""
def __init__(self, value=0):
self.value = value
def __getstate__(self):
return self.value
def __setstate__(self, value):
self.value = value
def set(self, value):
self.value = value
def _p_resolveConflict(self, old, first_id, second_id):
return max(first_id, second_id)
def _p_independent(self):
# My state doesn't depend on or materially effect the state of
# other objects.
return 1
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