I guess it can be done in one line but it would not change the logic

db.mytable <http://db.mytable.id/>[1] = 
dict(listfield=db.mytable<http://db.mytable.id/>
[1].listfield+[newelement])



On Tuesday, 3 April 2012 03:21:26 UTC-5, Manuele wrote:
>
> Il 02/04/2012 16:05, bussiere adrien ha scritto:
> > ok i thought about this too.
> > But when you have a looooooooooooooooooooooooooooooooooooooooooooong 
> > list that's not really nice.
> > And it take twolines.
> >
> > Summon Massimo can't we make a one line methode to do that ?
> >
> >
>
> c'mon two lines are not too much ;), consider that the length of your 
> list it's not important and the solution is always the same. Somethig  
> like that I guess...
>
> row = db(db.mytable.id==1).select().first()
> row.update_record(listfield=row.listfield+[newelement])
>
> in this way you can add new elements. If you want to delete one or more 
> element mantaining a two lines solution you can use instead:
>
> row.update_record(listfield=[i for i in row.listfield if i not in 
> [oldelement]])
>
> hope it could be of any help
>
>
> Cheers
>
>      Manuele
> >
> > Regards and thanks
> > Bussiere
>
>

Reply via email to