that's correct Richard, I use the same foreign key name in two tables. But 
how to handle properly as you imply?  Give it some sort of alias name 
somewhere?

In below form, field organization_fk exists in both tables 
db.auth_membership, and db.meeting_segment.  organization_fk is not 
mentioned in the form because it has default value and is hidden from user.

    form_add_new_meeting_segment = SQLFORM.factory(db.SuperObject, 
db.meeting_segment, db.auth_membership)
    if form_add_new_meeting_segment.process().accepted: 
        form_add_new_meeting_segment.vars.display_name = 
form_add_new_meeting_segment.vars.object_display_name = 
'%(meeting_segment_title)s' % form_add_new_meeting_segment.vars
        superObjectID = 
db.SuperObject.insert(**db.SuperObject._filter_fields(form_add_new_meeting_segment.vars))
        form_add_new_meeting_segment.vars.super_object_fk = superObjectID
        specificMeetingSegmentID = 
db.meeting_segment.insert(**db.meeting_segment._filter_fields(form_add_new_meeting_segment.vars))
        
db.auth_membership.insert(**db.auth_membership._filter_fields(form_add_new_meeting_segment.vars))
        db(db.SuperObject.id == superObjectID).update(applicable_table_row 
= specificMeetingSegmentID)
    if form.process().accepted:
        session.flash = str('Success. Added new meeting segment: ' + 
str(specificSegmentID))
        redirect(URL('default', 'view_specific_meeting', vars = 
dict(specificOrganizationID = specificOrganizationID, 
specificMeetingSegmentID = specificMeetingSegmentID)))  
    elif form_add_new_meeting_segment.errors:
        session.flash = T('Errors. Scroll down to see.')
    return locals() 


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to