In your case categores is a DAL rows object. there are many things you can 
do with in the view:

1) embed it

{{=categories}}

2) loop over the Rows

<ul>
{{for row in categories:}}
<li>{{=row.name}}</li>
{{pass}}
</lu>

3) convert it into a json table

<script>
var categories = {{=XML(categories.as_json())}};
</script>

4) I understand you are using this:
http://www.decalage.info/en/python/html

In that case you have to convert the Rows object into a python list of 
lists (table?)

table_data = [[row.id, row.name, ...] for row in categories]]

than in view:

{{=XML(*HTML.table*(table_data))}}

Hope this helps.

On Sunday, 22 February 2015 20:09:33 UTC-6, Abhijit Chatterjee wrote:
>
> This is not the right way to use web2py view but there is a html.py 
> package that converts table and list to html automatically. I am trying to 
> use that to see if it works out in web2py. More for an experiment than 
> anything. This question may be more of a python question than web2py but 
> here it is:
>
> In web2py controller I have category defined (This is an example from 
> reddit clone that Massimo presented)
>
>
>
> *def categories():    categories = 
> dbOBJECT(dbOBJECT.category).select(orderby=dbOBJECT.category.name 
> <http://dbobject.category.name/>)    return locals()*
>
> In the view when I do the following it display the categories (since its 
> same as response.write) :
>
> {{=categories}}
>
> I can see the following in html (see below). does someone know how would I 
> save that categories in a variable in the view (.html page) to create a 
> table variable? '
>
> Lets say save it in variable = ['Entertainment', 'News', 'Sports'] without 
> using for loops {{from category in categories}}? Any example you can point 
> me to?
>
> *category.id* <http://category.id/>*category.name* <http://category.name/>
> 1Entertainment2News3
>
> Sports     
>
>
> The idea would be to cat few of these tables together and use HTML.table 
> (variable) to display in the view without ever to use html syntax. Not sure 
> if its possible and probably not recommended, but wanted to try for fun.
>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to