コード例 #1
0
 def _to_python(self, value, state):
     """Parse a string and return a float or integer."""
     if isinstance(value, basestring):
         try:
             value = format.parse_decimal(value)
         except ValueError:
             pass
     return validators.Number.to_python(value, state)
コード例 #2
0
 def _to_python(self, value, state):
     """Parse a string and return a float or integer."""
     try:
         return format.parse_decimal(value)
     except ValueError:
         raise Invalid(self.message('badFormat', state), value, state)