Commit a446eebf authored by Vincent Pelletier's avatar Vincent Pelletier

Make getPassword default value behave consistently between cases where...

Make getPassword default value behave consistently between cases where password is of Persistent Mapping type and cases where it is not.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27638 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5ec0d9eb
...@@ -243,27 +243,23 @@ class Person(XMLObject): ...@@ -243,27 +243,23 @@ class Person(XMLObject):
Default: 'default' Default: 'default'
""" """
marker = [] marker = []
if len(args):
default_password = args[0]
else:
default_password = None
password = getattr(aq_base(self), 'password', marker) password = getattr(aq_base(self), 'password', marker)
if password is marker: if password is marker:
if len(args): password = default_password
password = args[0]
else:
password = None
else: else:
format = kw.get('format', 'default') format = kw.get('format', 'default')
# Backward compatibility: if it's not a PersistentMapping instance, # Backward compatibility: if it's not a PersistentMapping instance,
# assume it's a monovalued string, which corresponds to default # assume it's a monovalued string, which corresponds to default
# password encoding. # password encoding.
if isinstance(password, PersistentMapping): if isinstance(password, PersistentMapping):
password = password.get(format, marker) password = password.get(format, default_password)
if password is marker:
if len(args):
password = args[0]
else:
password = None
else: else:
if format != 'default': if format != 'default':
password = None password = default_password
return password return password
# Time management # Time management
......
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