Hello,
I'm trying to use the new methods for many-to-many relationships. I've
taken a small program using the recipes database from the PyCon
tutorial: just one window with a datagrid showing the recipes and a
checklist showing the categories, with the categories for the selected
recipe checked. Just as in the tutorial application.
I've changed that to use the m-m methods, but now the datagrid shows the
recipes several times: one row per associated category.
The "recipes" and "reccats" bizobjs are unchanged from the tutorial. No
"reccat" bizobj any more.The datagrid is created with
DataSource="recipes", no change here.
New createBizobjs method:
def createBizobjs(self):
conn = self.Application.getConnectionByName("recipesConnPK")
parentbiz = BizRecipes(conn)
self.addBizobj(parentbiz)
mmbiz = BizCategories(conn)
self.addBizobj(mmbiz)
parentbiz.addMMBizobj(mmbiz, "reccat", "recid", "catid")
The doUpdate method of the class CklCategories is changed, but that
shouldn't do anything to the datagrid, should it?
def doUpdate(self):
if self._needChoiceUpdate:
self.updateChoices()
biz = self.Form.getBizobj("recipes")
mmbiz = self.Form.getBizobj("reccats")
keyvalues = []
for mmval in biz.mmGetAssociatedValues(mmbiz, ["id"]):
keyvalues.append(mmval["id"])
self.KeyValue = keyvalues
print "Categories for this recipe: %s" % keyvalues
Should I put the complete script to dabo.codepad.org? It's not very long.
I didn't find an example for many-to-many relationships in the wiki and
the tutorial doesn't use the new methods. Did I overlook anything?
Thank you,
Sibylle
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]