From: Maurits v. R. <svn...@pl...> - 2009-04-24 23:48:11
|
Author: maurits Date: Fri Apr 24 23:47:57 2009 New Revision: 11055 Modified: Products.validation/branches/1.6/Products/validation/chain.py Products.validation/branches/1.6/docs/HISTORY.txt Log: Cut the validation short when there is only one validator and this validator is 'sufficient', which means it does not need to validate. Modified: Products.validation/branches/1.6/Products/validation/chain.py ============================================================================== --- Products.validation/branches/1.6/Products/validation/chain.py (original) +++ Products.validation/branches/1.6/Products/validation/chain.py Fri Apr 24 23:47:57 2009 @@ -128,6 +128,14 @@ """ results = {} failed = False + if len(self) == 1: + mode = [m for (v, m) in self][0] + if mode == V_SUFFICIENT: + # There is only one validator and its mode is + # 'sufficient' which means it does not have to + # validate. So we cut the validation short. + return True # validation was successful + for validator, mode in self: name = validator.name result = validator(value, *args, **kwargs) Modified: Products.validation/branches/1.6/docs/HISTORY.txt ============================================================================== --- Products.validation/branches/1.6/docs/HISTORY.txt (original) +++ Products.validation/branches/1.6/docs/HISTORY.txt Fri Apr 24 23:47:57 2009 @@ -4,6 +4,10 @@ 1.6.4 - unreleased ------------------ +* Cut the validation short when there is only one validator and this + validator is 'sufficient', which means it does not need to validate. + [maurits] + * Removed an unnecessary call on Zope startup to the test method in chain.py. [maurits] |