#799: Number validator isn't called if input is empty
------------------------------------+---------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone:
Component: Widgets | Version: 0.9a4
Severity: normal | Resolution:
Keywords: |
------------------------------------+---------------------------------------
Changes (by [EMAIL PROTECTED]):
* type: enhancement => defect
* summary: [PATCH] Add allow_empty attribute to the Number validator =>
Number validator isn't called if input is empty
Comment:
Hey...
I attached this patch without testing it (my bad, but it was a straight
CnP from the money validator), and I noticed that it didn't work. So, I
went off investigating and noticed that if I put a big phat print
statement as the first line of Number.to_python:
class Number(FancyValidator):
messages = {
'empty': 'Empty values not allowed',
}
def __init__(self, allow_empty = True, *args, **kwargs):
self.allow_empty = allow_empty
def _to_python(self, value, state):
""" parse a string and returns a float or integer """
print "********** I WAS CALLED ******************"
I don't see it in my log if the input is empty (ie. it is "" or u"").
Surely this can't be right?
My form is:
class BidForm(WidgetsList):
bid = TextField(label="Bid", validator=Number(allow_empty=False))
The data I get through to my controller is "None" - which is not a number,
by the way.
Cheers
-Rob
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/799>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" 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-tickets
-~----------~----~----~----~------~----~------~--~---