Does represent works with a simple sqlrow?

37 views
Skip to first unread message

Elcimar

unread,
Sep 13, 2011, 12:59:41 PM9/13/11
to web2py-users
Hi folks, newbie question here.
I have a table 'mensagens' with a field:

SQLField("usuario", "integer", length=255, notnull=True, default=None,
represent = lambda id: db.acessos[id].nick)

Then, after adding some data to this table I try to view some records:

registros = SQLTABLE(db().select(db.mensagens.ALL))

It works fine. But I don't need an SQLTABLE right now, I just need the
data, but if I do this:

registros = db().select(db.mensagens.ALL)

The 'represented' field shows its actual id instead of a 'nick'.

What should I do?



Anthony

unread,
Sep 13, 2011, 2:05:33 PM9/13/11
to web...@googlegroups.com
You can always call the represent function directly. E.g.:

db.mensagens.usario.represent(registros.first().usario)

Also, you should use Field() instead of SQLField() (no difference, but the latter has been deprecated).

Anthony 

rober...@gmail.com

unread,
Sep 13, 2011, 2:28:50 PM9/13/11
to web...@googlegroups.com
This small detail I think is affecting grid and powergrid not think it should be solved that way

Anthony <abas...@gmail.com> escribió:

Anthony

unread,
Sep 13, 2011, 2:45:36 PM9/13/11
to web...@googlegroups.com
On Tuesday, September 13, 2011 2:28:50 PM UTC-4, Roberto Perdomo wrote:
This small detail I think is affecting grid and powergrid not think it should be solved that way

I agree. He didn't say he was using grid or powergrid, though.

Anthony

Elcimar

unread,
Sep 14, 2011, 1:07:20 PM9/14/11
to web2py-users
Thanks for the tip Anthony!

Btw, I'm not using grid or powergid.
Reply all
Reply to author
Forward
0 new messages