Solved it.  I added a validator, now that I understand how they work.
My code now looks like this:  (Notice I changed ReachSchema() to
define the columns and ReachForm() to use ReachSchema() as a
validator.

class ReachFields(WidgetsList):
    """Replace to your Fields"""
    reach = TextField(label="reach")
    turnout = TextField(label="turnout")
    serialnumber = TextField(label="serialnumber")
    cfs = TextField(label="cfs")

class ReachSchema(validators.Schema):
    """
    separate validation schema from the fields definition
    make it possible to define a more complex schema
    that involves field dependency or logical operators
    """
    reach = validators.String(not_empty=True, max=45)
    turnout = validators.String(not_empty=False, max=45)
    serialnumber = validators.String(not_empty=False, max=8)
    cfs = validators.Number()

class ReachForm(TableForm):
    #name="Reach"
    fields = ReachFields()
    validator = ReachSchema() # define schema outside of ReachFields
    #method="post"
    submit_text = "Create"

On Apr 20, 3:23 pm, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> AZMel <[EMAIL PROTECTED]> writes:
> > Anyone come across this issue?
>
> > The model looks like this:
>
> > class Reach(SQLObject):
> >     class sqlmeta:
> >       table = "Reach"
> >     reach = StringCol(length=45)
> >     turnout = StringCol(length=45)
> >     serialnumber = StringCol(length=8)
> >     cfs = IntCol(default=0)
>
> (...)
>
> > Invalid: expected an int in the IntCol 'cfs', got <type 'unicode'>
> > u'12' instead
>
> All data that comes from the web is a string (or unicode string).  You
> have to convert it to the required type or pass it through a validator
> (that will, among other things, do the conversion for you).
>
> --
> Jorge Godoy      <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to