TurboGears / tg2

Python web framework with full-stack layer implemented on top of a microframework core with support for SQL DBMS, MongoDB and Pluggable Applications
http://www.turbogears.org/
Other
803 stars 77 forks source link

fix the bug which prevent param get it's default value #103

Closed shaverlee closed 5 years ago

shaverlee commented 5 years ago

` @validate(validators={'id' : validators.Int()}) @expose('json') def post(self, id=0) : assert(id == 0)

xxx.post() ` id will get a value None, instead of it's default value 0

amol- commented 5 years ago

Thanks for inspecting your issue!

But, this is not a bug, it's the intended purpose. The validator default value wins over the action default value. (and the validator default value, by default is None). You have to use @validate(validators={'id' : validators.Int(if_empty=0)})