Sorry Massimo, I left out part of the data model, which shows that auth_user can't be an element in the Party table.
Party can be either an organization or person, and organizations don't have auth_user fields. See data model examples: - http://www.tsjensen.com/blog/post/2009/01/03/Party+Role+And+Party+Type+In+Data+Model.aspx - http://www.tdan.com/view-articles/5014/ - http://www.essentialstrategies.com/publications/modeling/advanceddm.htm Here's the real data model db.define_table('Party', ## super-type for people and organizations Field('partyTypeID','reference PartyType'), ## partyType is either person or organization Field('displayName','string')) db.define_table('Organization', Field('partyID', 'reference Party'), Field('organizationShortName','string'), Field('organizationFullName','string')) auth.settings.extra_fields['auth_user']= [ Field('partyID', 'reference Party'), Field('personMiddleName','string'), Field('gender','string'), ] So to get the names to display in a compute = lambda statement, a join would be required every time the table is listed. I think that would be too big of a database hit. Instead, I can populate displayName but make sure that all update functions keep displayName accurate. Thanks, Alex On Monday, May 6, 2013 5:52:48 AM UTC-7, Massimo Di Pierro wrote: > > You need to link Party to user not vice versa: > > auth.settings.extra_fields['auth_user']= [ > # Field('partyID', 'reference Party'), > Field('personMiddleName','string'), > Field('gender','string'), > ] > > > db.define_table('Party', ## super-type for people and organizations > Field('user_id','reference auth_user'), > Field('partyTypeID','reference PartyType'), > Field('displayName','string')) > > db.Party.displayName.compute = lambda row: "%(first_name)s %(last_name)s" > % db.auth_user[row.user_id] > > > > On Monday, 6 May 2013 00:01:17 UTC-5, Alex Glaros wrote: >> >> In the controller below, how would I get auth_user.*first_name* and >> auth_user.*last_name* (concatenated) into table Party, field *displayName >> *? >> >> In other words, I'd like field displayName to end up with first_name and >> last_name inside it. >> >> Party is the parent table and auth_user is the child table. Party is a >> super-type that can be either a person or an organization. >> >> I think experienced programmers would recommend against hitting the >> database by joining Party table and auth_user table to create on-the-fly >> calculated field for displayName whenever a list of Party names is >> displayed, right? I just have to be careful to update displayName whenever >> first_name and last_name are subject to change. >> >> *Controller* >> >> def add_new_people(): >> db.auth_user.partyID.readable = db.auth_user.partyID.writable = False ## >> don't let user see field thinking they have to fill it in >> db.Party.partyTypeID.readable = db.Party.partyTypeID.writable = False ## >> don't let user see field thinking they have to fill it in >> form=SQLFORM.factory(db.Party,db.auth_user) >> db.Party.partyTypeID.default = 1 ## sets up db so it's a person, not >> organization >> if form.process().accepted: >> partyID = db.Party.insert(**db.Party._filter_fields(form.vars)) >> form.vars.partyID=partyID >> partyID = db.auth_user.insert(**db.auth_user._filter_fields(form. >> vars)) >> response.flash='Thanks for filling the form' >> return dict(form=form) >> >> >> *Model* >> >> auth.settings.extra_fields['auth_user']= [ >> Field('partyID', 'reference Party'), >> Field('personMiddleName','string'), >> Field('gender','string'), >> ] >> >> >> db.define_table('Party', ## super-type for people and organizations >> Field('partyTypeID','reference PartyType'), >> Field('displayName','string')) >> >> >> 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.

