On Nov 30, 10:59 am, SaltyCow <[email protected]> wrote:
> Thanks for the help. For some reason, though, the compute function
> doesn't like when 'id' is referred to in this way and throws the
> exception "KeyError: 'id'". I also looked into creating a custom
> validator, which I think would be handy if I wanted to do something
> more complex. But then I thought that all I'm really trying to do here
> is show users a "friendly" version of the primary key that already
> exists, so I chose to use the represent function:
>
> Field('id','id',
>           represent=lambda id:SPAN('Q',str(id+100000),'
> ',A('view',_href=URL('firm_read',args=id))))

Nothing wrong with it.
A bit speedier: SPAN('Q%s' %(id+100000))
or if you don't want the '1' after the Q
SPAN('Q%06d' %id)

> It's not a very sophisticated solution, but it seems to work without
> creating the overhead of maintaining an additional key field. If
> anyone sees a huge flaw in this approach, please let me know.
>
> Regards. >Jeff

Reply via email to