Sure. To avoid packing it all into a lambda, I would create a separate 
function:

def rsa_represent(id, row):
    record = db((db.RelationshipSubjectArea.id == id) &
                (db.RelationshipSubjectArea.subjectAreaID == db.SubjectArea.
id)).select().first()
    return '%s %s' % (record.SubjectArea.subjectAreaCode, record.
RelationshipSubjectArea.relationshipCode)

db.RelationshipRole.relationshipSubjectAreaID.represent = rsa_represent

I will leave it as an exercise to do it using recursive selects. ;-)

Anthony

On Wednesday, May 22, 2013 5:26:49 PM UTC-4, Alex Glaros wrote:
>
> Anthony,
>
> Is there a way to concatenate two "represent" fields for 
> db.RelationshipSubjectArea: '%(subjectAreaCode)s %(relationshipCode)'  in 
> your statement below: 
> db.RelationshipRole.relationshipSubjectAreaID.requires = IS_IN_DB(db, 
> 'RelationshipSubjectArea.id', lambda r: 
> db.SubjectArea(r.subjectAreaID).subjectAreaCode, zero=T('choose one'))
> OR IN
> db.RelationshipRole.relationshipSubjectAreaID.represent = lambda id, r: 
> db((db.RelationshipSubjectArea.id == id) & 
> (db.RelationshipSubjectArea.subjectAreaID == db.SubjectArea.id
> )).select().first().SubjectArea.subjectAreaCode
>
> The reason is that the other field, relationshipCode (e.g., "Employer and 
> Employee" value), needs to be displayed for users to understand which 
> choice they're making. See attached image.
>
> Thanks for your comprehensive answers already provided!
>
> I appreciate you reading through the many record relations and providing 
> detailed examples.
>
> Your solutions work great.
>
> Alex
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to