[Erp5-report] r25616 - /erp5/trunk/products/ERP5/Document/Person.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Feb 18 18:51:59 CET 2009
Author: vincent
Date: Wed Feb 18 18:51:56 2009
New Revision: 25616
URL: http://svn.erp5.org?rev=25616&view=rev
Log:
Improve default-value support to improve backward compatibility:
- return None when no password is set and no default was provided, instead of raising
- return default (or None) when requested encoding is not present (even if password value is a string)
Modified:
erp5/trunk/products/ERP5/Document/Person.py
Modified: erp5/trunk/products/ERP5/Document/Person.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Person.py?rev=25616&r1=25615&r2=25616&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Person.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Person.py [utf8] Wed Feb 18 18:51:56 2009
@@ -227,26 +227,35 @@
default (anything)
Value to return if no passord is set on context.
- Default: no default, raises AttributeError if property is not set.
+ Default: None
format (string)
String defining the format in which the password is expected.
If passowrd is not available in that format, KeyError will be
raised.
Default: 'default'
"""
- password = getattr(aq_base(self), 'password', *args)
- format = kw.get('format', 'default')
- try:
+ marker = []
+ password = getattr(aq_base(self), 'password', marker)
+ if password is marker:
+ if len(args):
+ password = args[0]
+ else:
+ password = None
+ else:
+ format = kw.get('format', 'default')
# Backward compatibility: if it's not a PersistentMapping instance,
# assume it's a monovalued string, which corresponds to default
# password encoding.
if isinstance(password, PersistentMapping):
- password = password[format]
+ password = password.get(format, marker)
+ if password is marker:
+ if len(args):
+ password = args[0]
+ else:
+ password = None
else:
if format != 'default':
- raise KeyError
- except KeyError:
- raise KeyError, 'Password is not available in %r format.' % (format, )
+ password = None
return password
# Time management
More information about the Erp5-report
mailing list