Ed Leafe wrote:
On May 15, 2006, at 9:38 PM, Paul McNett wrote:

Added the ability to set a bizobj LinkField to a table.field reference,
instead of merely a field reference. This appears to be essential to
making M:M joins work, where you don't have a bizobj defined for the
join table.

Implementing M:M support is going to be a lot more involved than that. I've started down this road many times, only to get stuck and then postpone further work. The main problem is under the hood, where you have cursors that need to be shared among more than one bizobj. I thought it would be simple to implement, but it gets hairy quickly, so a good design is going to be critical to making this work solidly.

Cool, but this change lets me hobble-through and get *something* working. Here's what I have:

1) Address book database with M:M relationship with categories. Addressbook table is a simple name, address, phone table. Categories are like "Paul's biz contacts", "Denise's School Contacts", "House Maintenance", etc. The tables involved are:

create table addressbook (id int primary key...)
create table addressbookcat (addressbook_id int, category_id int)
create table addressbookcats (id int primary key...)

2) Ran the AppWizard and selected "addressbook" and "addressbookcats".

3) Modified the bizobj for addressbookcats, adding:

class AddressbookCats_children(AddressbookCats):
        def initProperties(self):
                self.super()
                self.LinkField = "addressbookcat.addressbook_id"

        def setBaseSQL(self):
                self.super()
                self.addField("addressbookcat.addressbook_id as addressbook_id")
                self.setFromClause("""addressbookcat
 left join addressbookcats
   on addressbookcats.id = addressbookcat.category_id""")

4) Modified the generated ui/FrmAddressbook.py's afterInit() bizobj setup to read:

                # Instantiate the bizobj:
                app = self.Application
                primaryBizobj = app.biz.Addressbook(app.dbConnection)
                childBizobj = app.biz.AddressbookCats_children(app.dbConnection)
                primaryBizobj.addChild(childBizobj)

This results in the proper behavior under the hood, in that when I move to a different addressbook record, I can use the command window to verify that the getDataSet() of the child bizobj reflects being requeried properly.

The current problems are:

1) requerying child bizobjs when the main record changes results in near-unacceptable performance, even though my database is local. I'm pretty sure you allowed for delayed requerying, so I'll look into requerying the child manually when needed, instead of unconditionally.

2) There's something automatic happening inside datanav, because I'm getting another edit page that corresponds to the child bizobj. But I don't want to edit the child records, I just want to be able to put them into a grid to layout on my own. I don't want to edit the names of the categories from the address book form, but I do want to edit the category assignments - IOW, I want to insert/delete from the addressbookcat join table.

--
Paul McNett
http://paulmcnett.com
http://dabodev.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to