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.PartyPhoneNumberIntersection.countryTelephoneCode.represent = lambda id
> ,row:
>     db(db.Country.countryTelephoneCode == row.countryTelephoneCode).select
> ().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.PartyPhoneNumberIntersection.countryTelephoneCode.represent = lambdaid
>> ,row: db.Country(row.countryTelephoneCode).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.PartyPhoneNumberIntersection.countryTelephoneCode.represent = lambdaid
>>> ,row: db.Country(countryTelephoneCode).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 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