Hi everyone!, I'm developing a site which have 3 forms in one page, and one
of them have multiples selection fields.

I'm facing an error when the form is processed and I have not been able to
fix it.

Error:


*<type 'exceptions.TypeError'> string indices must be integers, not str*


*locals*

*c*

:

''

*component_list*

:

[[''], [<gluon.html.OPTION object>], [<gluon.html.OPTION object>],
[<gluon.html.OPTION object>], [<gluon.html.OPTION object>]]

*options*

:

<itertools.chain object>

*self*

:

<gluon.html.SELECT object>

*value*

:

'Boulder'



*Function argument list*

(self=<gluon.html.SELECT object>)

*Code listing*

        value *= **self**[*'value'*]*

        *if *value *is not None**:*

            *if not self**[*'_multiple'*]:*

                *for *c *in *options*:  **# my patch*

                    *print**(**c**[**'_value'**])*

                    *if **(*value *is not None**) **and **(*str*(*c*[*
'_value'*]) == *str*(*value*)):*

                        c*[*'_selected'*] = *'selected'

                    *else**:*

                        c*[*'_selected'*] = **None*


Looks like the problem is in: Field("Modalidad",
requires=IS_IN_SET(modalidades)),

“modalidades” is a list of strings, it works good when I call this form,
but when is processed it shows the above error…


Any help is really  appreciated



Part of the db.py


grados = ["todos","Rutas escuelas",

          "5.9","5.10a","5.10b","5.10c","5.10d","5.11a",

          "5.11b","5.11c","5.11d","5.12a","5.12b","5.12c",

          "5.12d","5.13a","5.13b","5.13c","5.13d","5.14a",

          "5.14b","5.14c","5.14d","5.15a","5.15b","5.15c"]

grados_roca = ["todos","Rutas escuelas","5.9/5c","5.10a/6a","5.10b/6a+",
"5.10c/6b","5.10d/6b+","5.11a/6c","5.11b/6c/c+","5.11c/6c+",

               "5.11d/7a","5.12a/7a+","5.12b/7b","5.12c/7b+","5.12d/7c",
"5.13a/7c+","5.13b/8a","5.13c/8a+","5.13d/8b",

               "5.14a/8b+","5.14b/8c","5.14c/8c+","5.14d/9a","5.15a/9a+",
"5.15b/9b"]

grados_boulder = ["todos","V1/5","V2/5+","V3/6a","V3/4/6a+","V4/6b",
"V4/5/6b+","V5/6c","V5/6/6c+","V6/7a","V7/7a+","V8/7b","V8/9/7b+","V9/7c",

                  "V10/7c+","V11/8a","V12/8a+","V13/8b","V14/8b+","V15/8c",
"V16/8c+"]


modalidades = ["todas", "Boulder", "Deportiva", "Tradicional", "Multilargo",
"Hielo"]

modalidades_add_ruta = ["Boulder", "Deportiva", "Tradicional", "Multilargo",
"Hielo"]

tipo = ["Monolargo","Multilargo"]



Form with problems:


agregar_ruta = SQLFORM.factory(Field("nombre_ruta", requires=IS_NOT_EMPTY())
,



                               Field("Tipo", default='Monolargo', requires
=IS_IN_SET(tipo)),

                               Field("Grado", default=grados_roca[2],

                                     requires=IS_IN_SET(range(1,
(len(grados_roca)
+ 1)), grados_roca)),

                               Field("Zona", default=zonas_list[0],

                                     requires=IS_IN_SET(zonas_list,
zonas_list_name)),

                               Field("Descripcion", 'text', length=300,

                                     default='No se ha registrado
descripción', label="Descripción"),

                               _name="agregar_ruta",

                               submit_button="Agregar",

                               )




Cheers!

Chris.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to