Correct lockhandler's handling of lock-lists

This commit is contained in:
Griatch 2017-08-31 20:58:34 +02:00
parent 328616d24e
commit b737c209b1

View file

@ -292,18 +292,25 @@ class LockHandler(object):
Add a new lockstring to handler. Add a new lockstring to handler.
Args: Args:
lockstring (str): A string on the form lockstring (str or list): A string on the form
`"<access_type>:<functions>"`. Multiple access types `"<access_type>:<functions>"`. Multiple access types
should be separated by semicolon (`;`). should be separated by semicolon (`;`). Alternatively,
a list with lockstrings.
Returns: Returns:
success (bool): The outcome of the addition, `False` on success (bool): The outcome of the addition, `False` on
error. error.
""" """
if isinstance(lockstring, basestring):
lockdefs = lockstring.split(";")
else:
lockdefs = [lockdef for locks in lockstring for lockdef in locks.split(";")]
lockstring = ";".join(lockdefs)
# sanity checks # sanity checks
for lockdef in lockstring.split(';'): for lockdef in lockdefs:
if ':' not in lockstring: if ':' not in lockdef:
self._log_error(_("Lock: '%s' contains no colon (:).") % lockdef) self._log_error(_("Lock: '%s' contains no colon (:).") % lockdef)
return False return False
access_type, rhs = [part.strip() for part in lockdef.split(':', 1)] access_type, rhs = [part.strip() for part in lockdef.split(':', 1)]