fixed problem with IS_INT_IN_RANGE for large numbers

This commit is contained in:
mdipierro
2013-10-11 16:59:05 -05:00
parent 59290534bc
commit d8e8d1d597
3 changed files with 7 additions and 18 deletions

View File

@@ -1 +1 @@
Version 2.7.2-stable+timestamp.2013.10.09.11.56.54
Version 2.7.2-stable+timestamp.2013.10.11.16.58.14

View File

@@ -6926,7 +6926,7 @@ def sqlhtml_validators(field):
elif field_type == 'double' or field_type == 'float':
requires.append(validators.IS_FLOAT_IN_RANGE(-1e100, 1e100))
elif field_type in ('integer','bigint'):
requires.append(validators.IS_INT_IN_RANGE(-1e100, 1e100))
requires.append(validators.IS_INT_IN_RANGE(-2**31, 2**31-1))
elif field_type.startswith('decimal'):
requires.append(validators.IS_DECIMAL_IN_RANGE(-10**10, 10**10))
elif field_type == 'date':

View File

@@ -692,7 +692,7 @@ class IS_INT_IN_RANGE(Validator):
>>> IS_INT_IN_RANGE(1,5)(5)
(5, 'enter an integer between 1 and 4')
>>> IS_INT_IN_RANGE(1,5)(3.5)
(3, 'enter an integer between 1 and 4')
(3.5, 'enter an integer between 1 and 4')
>>> IS_INT_IN_RANGE(None,5)('4')
(4, None)
>>> IS_INT_IN_RANGE(None,5)('6')
@@ -741,24 +741,13 @@ class IS_INT_IN_RANGE(Validator):
% dict(min=self.minimum, max=self.maximum - 1)
def __call__(self, value):
try:
fvalue = float(value)
if value and str(value).isdigit():
value = int(value)
if value != fvalue:
return (value, self.error_message)
if self.minimum is None:
if self.maximum is None or value < self.maximum:
return (value, None)
elif self.maximum is None:
if value >= self.minimum:
return (value, None)
elif self.minimum <= value < self.maximum:
return (value, None)
except ValueError:
pass
if ((self.minimum is None or value >= self.minimum) and
(self.maximum is None or value < self.maximum)):
return (value, None)
return (value, self.error_message)
def str2dec(number):
s = str(number)
if not '.' in s: