Skip to content

Commit

Permalink
Merge branch 'bugfix.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
lambacck committed Dec 15, 2012
2 parents 978ed1a + df66b54 commit 4c91912
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 244 deletions.
Binary file removed .coverage
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ dist/
# When you run ``python setup.py [test|nosetests]``
# from project's root tree, the script checks [and downloads, if necessary]
# packages which are specified in setup.py -> tests_require.
# Therefore we must explicitly ignore all downloaded *.egg packages.
# Therefore we must explicitly ignore all downloaded *.egg packages
# as well as all coverage-related files.
*.egg
*coverage*
1 change: 1 addition & 0 deletions formencode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class Validator(declarative.Declarative):
if_missing = NoDefault
repeating = False
compound = False
accept_iterator = False
gettextargs = {}
use_builtins_gettext = True # In case you don't want to use __builtins__._
# although it may be defined, set this to False
Expand Down
15 changes: 15 additions & 0 deletions formencode/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def from_python(validator, value, state):
class CompoundValidator(FancyValidator):

if_invalid = NoDefault
accept_iterator = False

validators = []

Expand Down Expand Up @@ -105,6 +106,13 @@ def is_empty(self, value):
# sub-validators should handle emptiness.
return False

def accept_iterator__get(self):
accept_iterator = False
for validator in self.validators:
accept_iterator = accept_iterator or getattr(validator, 'accept_iterator', False)
return accept_iterator
accept_iterator = property(accept_iterator__get)


class All(CompoundValidator):
"""
Expand Down Expand Up @@ -201,6 +209,13 @@ def is_empty(self, value):
# sub-validators should handle emptiness.
return False

def accept_iterator__get(self):
accept_iterator = True
for validator in self.validators:
accept_iterator = accept_iterator and getattr(validator, 'accept_iterator', False)
return accept_iterator
accept_iterator = property(accept_iterator__get)


class Pipe(All):
"""
Expand Down
1 change: 1 addition & 0 deletions formencode/foreach.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ForEach(CompoundValidator):

convert_to_list = True
if_empty = NoDefault
accept_iterator = True
repeating = True
_if_missing = ()

Expand Down
Loading

0 comments on commit 4c91912

Please sign in to comment.