Permalink
Browse files

Merge branch 'hotfix/2.1.6'

  • Loading branch information...
moschlar committed Jun 12, 2013
2 parents e3bcb87 + 146d172 commit a699822e56031a1a0aa351f7bae19ff58401af18
Showing with 10 additions and 10 deletions.
  1. +1 −1 setup.py
  2. +3 −3 tests/test_validation.py
  3. +3 −5 tw2/core/command.py
  4. +3 −1 tw2/core/validation.py
@@ -51,7 +51,7 @@ def get_description(fname='README.rst'):
setup(
name='tw2.core',
version='2.1.5',
version='2.1.6',
description="Web widget creation toolkit based on TurboGears widgets",
long_description = get_description(),
install_requires=requires,
@@ -425,9 +425,9 @@ def test_required(self):
class TestBoolValidator(tb.ValidatorTest):
validator = BoolValidator
to_python_attrs = [{}, {}, {}, {}, {}, {}, {}, {}, {},]
to_python_params = ['on', 'yes', 'true', '1', 1, True, 'Yes', 'True', 'off']
to_python_expected = [True, True, True, True, True, True, True, True, False]
to_python_attrs = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
to_python_params = ['on', 'yes', 'true', '1', 1, True, 'Yes', 'True', 'off', '', None]
to_python_expected = [True, True, True, True, True, True, True, True, False, False, False]
class TestOneOfValidator(tb.ValidatorTest):
validator = OneOfValidator
@@ -186,10 +186,8 @@ def _load_widgets(self, mod):
def _load_widget_entry_points(self, distribution):
try:
requires = [
r.project_name for r in
pkg_resources.get_distribution(distribution).requires()
]
dist = pkg_resources.get_distribution(distribution)
requires = [r.project_name for r in dist.requires()]
map(self._load_widget_entry_points, requires)
@@ -209,7 +207,7 @@ def _load_widget_entry_points(self, distribution):
#TODO -- this should be resolved and standardized in the future.
for ep in pkg_resources.iter_entry_points('tw2.widgets'):
if ep.module_name.startswith(distribution):
if ep.dist == dist:
mod = ep.load()
self._load_widgets(mod)
self.announce("Loaded %s" % mod.__name__)
@@ -199,6 +199,7 @@ class Validator(object):
}
required = False
strip = True
if_empty = None
def __init__(self, **kw):
for k in kw:
@@ -209,7 +210,7 @@ def to_python(self, value, state=None):
if self._is_empty(value):
if self.required:
raise ValidationError('required', self)
return None
return self.if_empty
if self.strip and isinstance(value, basestring):
value = value.strip()
value = self._convert_to_python(value, state)
@@ -385,6 +386,7 @@ class BoolValidator(RangeValidator):
msgs = {
'required': ('bool_required', _('You must select this'))
}
if_empty = False
def _convert_to_python(self, value, state=None):
return str(value).lower() in ('on', 'yes', 'true', '1', 'y', 't')

0 comments on commit a699822

Please sign in to comment.