Hi guys,
i'm just learning TG2 and i'm using tg2.0 I'm following this tutorial,
http://sprox.org/tutorials/table.html
and i'm using RestController cause i'm diplayng the data with a dojo table.
Let's say i want to display the detail of one record (with the get_one method).
The model is called  CompanyModel and i'm calling this url
http://localhost:8080/companies/1/
this is the controller

class CompaniesController(RestController):

  �...@expose('adamant.templates.sprox.companies.get_one')
   def get_one(self, id):
       company = DBSession.query(CompanyModel).get(id)
       print company.__mapper__.columns.keys()
       return dict(value=company)

and this is the view
...
<div id="table_display">
 <table class="adamant_table">
<tr py:for="i, col in enumerate(value.__mapper__.columns.keys())"
class="${i%2 and 'even' or 'odd'}">
<!-- tr py:for="col in value['items'][0].keys()" > <!  class="${i%2
and 'even' or 'odd'}" -->
<td>${col}</td>
<td>${value.__dict__[col]}</td>
<!-- td>${value['items'][0][col]}</td -->
</tr>
 </table>
   </div>
...
I want to display the detail page in a way like this
FieldName Value
in a vertical tabular way.
Is this the right way to display data or there is a shortcut?
One more question:
how can i normalize field name?
Sprox normalize field name from
user_name to User Name
is there a specific function for this?
Thanks in advance
Fabrizio

--

You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.


Reply via email to