replace (...) with [...] in

list=[(name,False,link,[newitem,False,link])] to make the respective
...
        catree[-1].append((supercat.nombre,False,'link'))


list=[[name,False,link,[newitem,False,link]]] to make the respective
...
        catree[-1].append([supercat.nombre,False,'link'])

On Feb 11, 11:39 am, w2padawan <web2py.n...@gmail.com> wrote:
> Hi,
>
> I'm loosing a lot of time trying to generate a categories menu from
> database, but my lack of experience in python seems to be yet too
> much.
>
> The respective error ticket says:
>
>     AttributeError: 'tuple' object has no attribute 'append'
>
> How can I list.append((newitem,False,link)) inside a
> list=[(name,False,link,[newitem,False,link])] to make the respective
> submenu from the query, if you know what I mean?
>
> CONTROLLER:
> ==================
> supercategorias =
> db(db.t_categoria.supercategoria==None).select(db.t_categoria.id,db.t_categ 
> oria.nombre)
> for supercat in supercategorias:
>         catree[-1].append((supercat.nombre,False,'link'))
>         cats = 
> db(db.t_categoria.supercategoria==supercat.id).select(db.t_categoria.nombre 
> ,db.t_categoria.id)
>         for cat in cats:
>             catree.append([cat.nombre,False,'link'])
> ----------------------------------------
>
> MODEL:
> =====================
> db.define_table("t_categoria",
>     Field('nombre','string'),
>     Field('supercategoria','string')
> )
>
> db.t_categoria.supercategoria.requires=IS_EMPTY_OR(IS_IN_DB(db,'t_categoria 
> .id','%(nombre)s',zero=T('[Seleccione
> sólo si corresponde]')))
> ---------------------------------------------
>
> VIEW:
> ============
> {{=MENU(catree)}}
> ---------------------------
>
> kind regards, and thank you for your time

Reply via email to