# HG changeset patch # User Julien Cristau # Date 1413540898 -7200 # Node ID 0a49d61c8ccaf64d0165a8cfb91d4426b2be4fbe # Parent 5907c2b0acd7e86e57e34e605077eba6992314e6 Add custom checker for Password values We override the default converter to pass Binary values through, but don't do anything about the checker. This worked previously because yams allowed StringIO instances, although its converter didn't do the right thing for them. Fixing this in yams requires that we properly register a checker. diff -r 5907c2b0acd7 -r 0a49d61c8cca __init__.py --- a/__init__.py Wed Oct 22 15:59:52 2014 +0200 +++ b/__init__.py Fri Oct 17 12:14:58 2014 +0200 @@ -42,7 +42,7 @@ from logilab.common.deprecation import deprecated from logilab.common.logging_ext import set_log_methods -from yams.constraints import BASE_CONVERTERS +from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS # pre python 2.7.2 safety logging.basicConfig() @@ -140,6 +140,10 @@ return cPickle.loads(zlib.decompress(self.getvalue())) +def check_password(eschema, value): + return isinstance(value, (str, Binary)) +BASE_CHECKERS['Password'] = check_password + def str_or_binary(value): if isinstance(value, Binary): return value