> It would be great if the new M:M methods are available (of course, I
> understand that it is subject to the availability of time for you).
> Anyways, ... looking forward eagerly for this new feature in dabo.
I haven't gotten much feedback on these changes, so either no one's using
them yet, or they're perfect. :)
If you run into any problems, please let me know.
-- Ed Leafe
----------------------------------
Hi !
I'm getting my feet wet with new methods for M:M relation handling.
This is how I coded the relationship---
Preamble: There are 3 tables
1) mdlmst (mdlmstid, mdlmstcd, mdlmstnm) : master conatining info about car
models
2) wrmst (wrmstid, wrmstcd, wrmstnm) : master conatining info about warranty
policies
3) mdlwr (mdlwrid, mdlmstid, wrmstid) : 'glue' table between 'mdlmst' & 'wrmst'
-----bo3.py----
import dabo
#connection object
testci = dabo.db.dConnectInfo(Host='myhost', DbType='MySQL',
Database='myschema', User='root', PlainTextPassword='mypswd')
testconn = dabo.db.dConnection(testci)
#class definitions for tables
class PublicWrmstBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource ='wrmst'
self.KeyField = 'wrmstid'
self.NonUpdateFields = ['wrmstid']
class PublicMdlmstBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource ='mdlmst'
self.KeyField = 'mdlmstid'
self.NonUpdateFields = ['mdlmstid']
#instantiate the classes
wrBizObj = PublicWrmstBizobj(testconn)
mdlBizObj = PublicMdlmstBizobj(testconn)
wrBizObj.requery()
mdlBizObj.requery()
#establish the M:M relationship
mdlBizObj.addMMBizobj(wrBizObj, 'mdlwr', 'mdlmstid', 'wrmstid')
#associate a record in mdlmstid with a record in wrmstid
mdlBizObj.seek(1, fld='mdlmstid')
mdlBizObj.mmAssociateValue(wrBizObj, 'wrmstid', 1)
Here, a traceback is thrown.
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "f:\py\dabovmd\bo3.py", line 117, in <module>
mdlBizObj.mmAssociateValue(wrBizObj, 'wrmstid', 1)
File "f:\py\dabo\biz\dBizobj.py", line 2113, in mmAssociateValue
assoc["cursor"].mmAssociateValue(otherField, otherVal)
File "f:\py\dabo\db\dCursorMixin.py", line 1157, in mmAssociateValue
return self.mmAddToBoth(self.KeyField, self.getPK(), otherField, otherVal)
File "f:\py\dabo\db\dCursorMixin.py", line 1227, in mmAddToBoth
thisPK = self.lookupPKWithAdd(thisField, thisVal, thisTable)
File "f:\py\dabo\db\dCursorMixin.py", line 1142, in lookupPKWithAdd
aux.execute(sql, (val,))
File "f:\py\dabo\db\dCursorMixin.py", line 386, in execute
raise dException.DBQueryException(errMsg)
DBQueryException: not all arguments converted during string formatting
----------------------------------
Maybe, I am not following the right procedure for M:M relationshiop.
On the python shell--
>>> bo3.mdlBizObj._getAssociation(bo3.wrBizObj)
{'bizobj': <dabovmd.bo3.PublicWrmstBizobj (baseclass dabo.biz.dBizobj,
id:94895376)>,
'cursor': <dabo.biz.dBizobj.cursorMix (baseclass dabo.biz.dBizobj.cursorMix,
id:94940496)>}
Can you pl. indicate the right procedure for setting M:M relationship &
manipulating records?
Thanks,
Vineet
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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]