You could do both queries within the lambda and put the results together with string formatting:
lambda id, r: '%s %s' % ( db((db.RelationshipType.id==id) & (db.RelationshipSubjectArea.id == db.RelationshipType. relationshipSubjectAreaID) & (db.RelationshipSubjectArea.subjectAreaID == db.SubjectArea.id) ).select().first().SubjectArea.subjectAreaCode, db.RelationshipType(id).relationshipTypeCode ) But to avoid doing the second query unnecessarily (since you already get that value in the first query), you can instead use a separate function: def rtid_represent(id, r): row = db((db.RelationshipType.id==id) & (db.RelationshipSubjectArea.id == db.RelationshipType. relationshipSubjectAreaID) & (db.RelationshipSubjectArea.subjectAreaID == db.SubjectArea.id) ).select().first() return '%s %s' % (row.SubjectArea.subjectAreaCode, row.RelationshipType. relationshipTypeCode) db.RelationshipRoleType.relationshipTypeID.represent = rtid_represent Anthony On Monday, June 10, 2013 3:19:08 AM UTC-4, Alex Glaros wrote: > > I'm trying to concatenate the results of two represents clauses for the > same field: "relationshipTypeID" The first "represents" clause returns > "subjectAreaCode" and the second returns "relationshipTypeCode". Without > all the queries, this could normally be accomplished by '%(field_1)s > %(field_2)s' format, but one of my represents uses a full query. > > I can't stack the "represents" clauses because the last one overwrites the > first one. How can I get both fields to display whenever the > "relationshipTypeID" field is used? Here are the two "represents" clauses: > > db.RelationshipRoleType.relationshipTypeID.represent = lambda id, r: db(( > db.RelationshipType.id==id) & (db.RelationshipSubjectArea.id == db. > RelationshipType.relationshipSubjectAreaID) & > (db.RelationshipSubjectArea.subjectAreaID > == db.SubjectArea.id)).select().first().SubjectArea.subjectAreaCode > > db.RelationshipRoleType.relationshipTypeID.represent = lambda id,row: db. > RelationshipType(id).relationshipTypeCode > > 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.