I'm a bit confused, I'm hoping someone can point in the right direction.  I 
would like to be left with a data structure similar to the following:

data = {
  'ids':  [ 1, 2, 8, 14, 15]
}

Assuming I build my form options with the following:
opts = [  x, "Option %d" % x for x in range(50) ]

Now I build a schema and intend to use a checkbox_choice widget:

class profSchema(colander.MappingSchema):
        ids = colander.SchemaNode(colander.Seq(),
                  widget=deform.widget.CheckboxChoiceWidget(
                          values=opts,
                        ),
                  )

This works up until the form is submitted, and then it fails with "IndexError: 
list index out of range" if any checkbox is selected. I have not been able to 
get it to work at all with colander.Seq(), perhaps I don't know how to use it 
properly. Meanwhile, it also allows for blank lists even though it is a 
required field.  I don't understand this.  As far as I can tell the above 
correct but refuses to work.

I switched to use deform.Set().  This works well.  Except for the fact that the 
data returned is all in string form:

data = {
        'ids': set([u'1', u'2', u'5'])
}

How do I require it to be ints, not strings?

In short can someone point me in the right direction on how to define a schema 
that has a field of a list of integers. 


Thanks in advance for any help.

Cheers, 
Ari
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to