No it does not. This is what I get:

>>> db.define_table('name',Field('value','list:string'))
>>> db.name.insert(value=['hello','world'])
1
>>> db.name(1).value
['hello', 'world']
>>> for row in db(db.name).select(): print row
<Row {'update_record': <function <lambda> at 0x1698f70>, 'value':
['hello', 'world'], 'id': 1, 'delete_record': <function <lambda> at
0x16a0030>}>

I think you inserted '|21.5|45.3|' instead of ['21.5','45.3'] and you
get back what you insert.


On Nov 23, 10:08 am, Bruno Rocha <[email protected]> wrote:
> HI, I am taking advantage of this thread to solve a doubt about
> list:string,
> How can I get the values from list:string field rendered as a Python 'list'
> ?
>
> Is there a ready way in DAL, or I need to use .split() and .join() ?
>
> look:
>
> >>> row = db(db.doacao.user_id==23).select()[0]
> >>> row
>
> <Row {'user_id': 23, 'exibir': True, 'twitter': None, 'update_record':
> <function <lambda> at 0x930ae64>, 'projeto': None, 'animais': '|12|20|',
> 'valores': '|21.5|45.3|', 'obs': None, 'sorteio': '5796', 'total': 20.0,
> 'data': datetime.datetime(2010, 11, 23, 10, 7, 48), 'id': 58,
> 'delete_record': <function <lambda> at 0x930ae2c>}>>>> row.animais
> '|12|20|'
> >>> row.valores
>
> '|21.5|45.3|'
>
> At this point the 'list:string' fields returns 'str' , I can split this by
> '|' and create a new list, but may be DAL has a function for doing that?
>
> 2010/10/25 mdipierro <[email protected]>
>
>
>
> > hmmmm. that is possible. Will look into it.
>
> > On Oct 25, 3:59 pm, yamandu <[email protected]> wrote:
> > > It seems that this widget does not work when there is more than one
> > > list:string field in a page.
>
> > > On Oct 25, 2:01 am, mdipierro <[email protected]> wrote:
>
> > > > The list:string is not an alternative to using a tag table and
> > > > tag_link many-to-many (an example of which is provided by
> > > > plugin_tagging).
>
> > > > Yet you should not have the problem you experience. With recent
> > > > versions of web2py, Field('keywords', 'list:string') should be
> > > > rendered by a new widget that takes one keyword per line and adds new
> > > > lines when yo press enter. You should not be using '|' to separate
> > > > keywords. If you do all keywords will be interpreted as one long
> > > > keyword containing the '|'s.
>
> > > > Massimo
>
> > > > On Oct 24, 10:35 pm, rick <[email protected]> wrote:
>
> > > > > I'm getting frustrated with the list:string field type.
>
> > > > > I store products, each product has "keywords" that describe the
> > > > > product.
> > > > > db.define_table('products',
> > > > >    Field('keywords', 'list:string'))
> > > > > I don't know what the keywords will be, so I can't use IS_IN_SET()
>
> > > > > It seems to stores the keywords fine, as long as (I'm using Crud)
> > > > > I separate the keywords like this: green|blue|red
>
> > > > > But when I make this call
> > > > > rows = db(db.products.keywords.contains(keyword)).select()
> > > > > I don't get all the products back that I should! In fact, it seems
> > > > > that I need to do an update on the product (again using Crud,
> > > > > and any sort of update) before the product's keywords will be
> > > > > picked up.
>
> > > > > Is this a problem with using Crud?
> > > > > In all honesty, I'd be more comfortable not using list:string, and
> > > > > having a separate table "keywords" that linked (many-to-one)
> > > > > to the products table, but I really don't know how I would even
> > > > > begin to do that in web2py..
>
> > > > > Thanks for reading!
> > > > > - rick
>
> --
>
> Bruno Rochahttp://about.me/rochacbruno/bio

Reply via email to