Loked at the source for SQLTABLE.
Setting linkto to None fixed it.

def index2():
    " List all blog posts "
    db.blog_posts.title.represent = lambda _: 'replace title'
    db.blog_posts.id.represent = lambda _: 'replace id'
    posts = crud.select(
        db.blog_posts,
        fields=['blog_posts.id', 'blog_posts.title'],
        linkto=None)
    return dict(posts=posts)

On Dec 16, 6:08 pm, hcvst <[email protected]> wrote:
> Hi,
>
> I'm struggling to change a table's records ID representation when
> using Crud.
> (w2p Version 1.89.5 (2010-11-21 22:12:54))
>
> def index1():
>     " List all blog posts "
>     db.blog_posts.title.represent = lambda _: 'replace title'
>     db.blog_posts.id.represent = lambda _: 'replace id'
>     posts = crud.select(
>         db.blog_posts,
>         fields=['id', 'title'])
>     return dict(posts=posts)
>
> def index2():
>     " List all blog posts "
>     db.blog_posts.title.represent = lambda _: 'replace title'
>     db.blog_posts.id.represent = lambda _: 'replace id'
>     posts = crud.select(
>         db.blog_posts,
>         fields=['blog_posts.id', 'blog_posts.title'])   # !!! field
> names prefixed by tablename
>     return dict(posts=posts)
>
> index1() doesn't change the representation at all. With index2() only
> the title's representation is changed.
> In both cases the id column displays the numeric id - However! with
> index2() the id is a link whereas with index1() it is not.
>
> I had the same problem a while back when crud.create still had a
> 'columns' parameter according to the w2p book (was it renamed to
> 'fields' recently?) but got it to work when I prefixed the field names
> by the table name as I did here in index2().
>
> Regards,
> HC

Reply via email to