'Replaces the lockstring entirely.
Args:
lockstring (str): The new lock definition.
Return:
success (bool): False if an error occurred.
Raises:
LockException: If a critical error occurred.
If so, the old string is recovered.'

def replace(self, lockstring):

    old_lockstring = str(self)
    self.clear()
    try:
        return self.add(lockstring)
    except LockException:
        self.add(old_lockstring)
        raise
