truemped/supercell — pull request #4 by tobigue (2013-10-15 16:04:15+00:00)
Title: Wrong user input (model can't be initialized) should return a 400 Error.

Currently wrong user input that results in a non-caught ValueError exception returns a 500 Error, while it should be a 400 Error.

This is how the ValueError happens:

>>> from schematics.models import Model
>>> from schematics.types import IntType
>>> class Schema(Model):
... number = IntType()
...
>>> Schema(**{"number": 1})

>>> Schema(**{"number": "one"})
Traceback (most recent call last):
File "", line 1, in
File "[...]/eggs/schematics-0.6-py2.7.egg/schematics/models.py", line 140, in __init__
setattr(self, attr_name, field_value)
File "[...]/eggs/schematics-0.6-py2.7.egg/schematics/types/base.py", line 423, in __set__
value = self.number_class(value)
ValueError: invalid literal for int() with base 10: 'one'