le 07.12.2007 01:06 Ben Sizer a écrit:
> I have a 'validators.Int()' which appears to be letting None values
> through. This seems to contradict
> http://docs.turbogears.org/1.0/ValidateDecorator
> which says that I can be assured that I will get an int. Basically I'm
> submitting an INPUT element to a form where the user is supposed to
> type a number, but they may just leave it blank. (I hope to coerce
> that to zero later.)
>
> Example:
>
> Template:
> <form method="POST" action="do_assign_bounty">
> <input type="text" name="newAmount" value="" size="7" />
> <input type="hidden" name="taskID" value="${task.id}" />
> </form>
>
> Controller:
> @expose()
>
> @validate(validators={"newAmount": validators.Int()})
>
You should try with adding not_empty = True as a parameter to Int like
this :
@validate(validators={"newAmount": validators.Int(not_empty=True)})
> def do_assign_bounty(self, taskID, newAmount, tg_errors=None):
> assert(tg_errors is None)
> assert(newAmount is not None)
>
> Traceback:
> File "E:\blah\blah\controllers.py", line 156, in do_assign_bounty
> assert(newAmount is not None)
> AssertionError: <bound method Settlement.do_assign_bounty of
> <my_proj.controllers.Settlement object at 0x01707530>>
>
>
> Am I doing something silly? Or is this functionality broken in some
> way? Or perhaps the docs are wrong?
>
> --
> Ben Sizer
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---