You just change this:

def rp(author):
    an =
db(db.akb_reprint.uuid==author).select(db.akb_reprint.rp_author)
    if len(an):
        a_name = an.first()['rp_author']
    else:
        a_name = 'No rp_author'
    return a_name

into this:

def rp(author,record):
    an =
db(db.akb_reprint.uuid==author).select(db.akb_reprint.rp_author)
    if len(an):
        a_name = an.first()['rp_author']
    else:
        a_name = 'No rp_author'
    return a_name

or

def rp(author,record):
    row =
db(db.akb_reprint.uuid==author).select(db.akb_reprint.rp_author).first()
    return row and row.rp_author or 'No author'

and use it as

db.akb_articles.rp_author.represent = rp


In this case you would not need record.

On Aug 25, 6:39 am, Johann Spies <johann.sp...@gmail.com> wrote:
> Please help me to understand how to use the new syntax.  How do I have to
> change the following code to work?
>
> def rp(author):
>     an =  db(db.akb_reprint.uuid==author).select(db.akb_reprint.rp_author)
>     if len(an):
>         a_name = an.first()['rp_author']
>     else:
>         a_name = 'No rp_author'
>     return a_name
>
> db.akb_articles.rp_author.represent = lambda x,record: rp(x),record
>
> How do I define and use 'record' in this case?
>
> The ticket says:
>
>  db.akb_articles.rp_author.represent = lambda x,record: rp(x),record
> NameError: name 'record' is not defined
>
> Regards
> Johann
>
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a

Reply via email to