They both worked beautifully, thanks Anthony.

(Note to anyone copying this, Google Groups formatted a hard return that
should be removed to make Anthony's examples work).

Alex

On Fri, Apr 19, 2013 at 10:15 PM, Anthony <[email protected]> wrote:

> Or slightly shorter:
>
> db.PartyPhoneNumberIntersection.countryTelephoneCode.represent = lambda id
> ,row:
>     db.Country(countryTelephoneCode=row.countryTelephoneCode).countryName
>
> Anthony
>
>
> On Saturday, April 20, 2013 1:13:19 AM UTC-4, Anthony wrote:
>>
>> Oh, yeah, forgot the code is not the id field of the Country table -- you
>> need a full query:
>>
>> db.PartyPhoneNumberIntersectio**n.countryTelephoneCode.represe**nt =
>> lambda id,row:
>>     db(db.Country.countryTelephone**Code == row.countryTelephoneCode).
>> sele**ct().first().countryName
>>
>> Anthony
>>
>> On Saturday, April 20, 2013 12:47:55 AM UTC-4, Anthony wrote:
>>>
>>> Notice that the current row is passed into the lambda, and
>>> countryTelephoneCode is a field in that row, so you have to refer to it as
>>> row.countryTelephoneCode:
>>>
>>> db.PartyPhoneNumberIntersectio**n.countryTelephoneCode.represe**nt =
>>> lambda id,row: db.Country(row.countryTelephon**eCode).countryName
>>>
>>> Anthony
>>>
>>> On Saturday, April 20, 2013 12:23:50 AM UTC-4, Alex Glaros wrote:
>>>>
>>>> What is the represent feature syntax for having countryName appear in
>>>> place of countryTelephoneCode using the represent feature?
>>>>
>>>> Notice in the above situation that countryTelephoneCode is not the
>>>> primary key of the Country table.
>>>>
>>>> db.define_table('Party', ## super-type for people and organizations
>>>> Field('partyTypeID','reference PartyType'),
>>>> Field('displayName','string'))
>>>>
>>>>
>>>> db.define_table('Country',
>>>> Field('countryName','string'),
>>>> Field('countryCode','string'),
>>>> Field('countryTelephoneCode','**integer'))
>>>>
>>>>
>>>> db.define_table('**PartyPhoneNumberIntersection',
>>>> Field('partyID','reference Party'),
>>>> Field('countryTelephoneCode','**integer'),
>>>> Field('telephoneNumber','**integer'))
>>>>
>>>>
>>>> db.PartyPhoneNumberIntersectio**n.countryTelephoneCode.represe**nt =
>>>> lambda id,row: db.Country(countryTelephoneCod**e).countryName  ## this
>>>> generates an error:  "global name 'countryTelephoneCode' is not defined"
>>>> How can I fix this represent syntax?
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Alex Glaros
>>>>
>>>>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/X3yCo4Vwqew/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to