Added a "replace" method to lockhandler, courtesy of patch by user Shell.

This commit is contained in:
Griatch 2012-09-30 17:37:05 +02:00
parent a4adc035f2
commit 049cc84be7

View file

@ -290,6 +290,16 @@ class LockHandler(object):
self.log_obj = None self.log_obj = None
return True return True
def replace(self, lockstring, log_obj=None):
"Replaces the lockstring entirely."
old_lockstring = str(self)
self.clear()
try:
return self.add(lockstring, log_obj)
except LockException:
self.add(old_lockstring, log_obj)
raise
def get(self, access_type): def get(self, access_type):
"get the lockstring of a particular type" "get the lockstring of a particular type"
return self.locks.get(access_type, None) return self.locks.get(access_type, None)