On Saturday, May 14, 2016 at 12:06:11 PM UTC-4, [email protected] wrote:
>
> Yes. in my case with request.args(0) into db.Post is a row object but 
> since its list:string I see a bracket around. So, question Anthony. How do 
> we take the html tag element out of row object. There are no examples in 
> the book about how to do that. We have to live with it?
>

You don't have to live with anything -- you just have to write some code.

And to be clear, there is no HTML tag in the row object or in the returned 
value for your field at all. You have created a list:-type field, so 
naturally the value you get from that field is a list. You cannot simply 
insert a Python list in an HTML view without doing something to specify how 
that list should be displayed. By default, the object's __str__ method will 
be called, which in the case of Python lists produces a comma-separated 
list of values inside brackets (same as if you display a list in a Python 
console). If you want something else, you have to write some code to 
generate the display you want.

By default, list:-type fields do get a default "represent" attribute that 
converts the list into a string of comma-separated values (with no 
brackets), but that function is only used in particular contexts where 
web2py is controlling the display (e.g., forms and the grid). You can also 
take advantage of the "represent" function by using Rows.render(), but for 
that, you obviously need a Rows object. That means you cannot do 
db.mytable(some_id), because that directly returns a Row object, not a Rows 
object. So, instead you would have to do db(db.mytable.id == 
some_id).select().render(0).

Anthony

-- 
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