Hi

I'm enjoying my dive with web2py.  I would like to seek help/pointers
re putting logic back at controller.

I have two tables,

db.define_table('person', Field('name'))

db.define_table('cats', Field('name'), Field('owner', db.person))

I have a controller default/index

def index():
    records = db().select(db.cats.ALL)
    return dict(records=records)

in index.html, I have

{{extend 'layout.html'}}
{{=A('insert record',_href=URL('create'))}}
<ul>
{{for record in records:}}
<li>
<b>{{=db(db.person.id == record.id).select().first().name}} </b>
{{=A('edit', _href=URL('edit', args=record.id))}}
{{=record.name}}
Majority: {{=record.majority}} | undi rosak: {{=record.undi_rosak}} |
jumlah undi: {{=record.jumlah_undi}} | %: {{=record.peratus}}
</li>
{{pass}}
</ul>

My Q: any way I can put
{{=db(db.person.id == record.id).select().first().name}}
somewhere else? e.g in controller?

I know I can use a function in my views, but think that would be a
problem should I have complex function?

tia
~

Reply via email to