On Sep 30, 2011, at 12:53 AM, Vineet Deodhar wrote:

> Coming to my code:
> Whether mmAddtoBoth(wrBizObj,"mdlmstid", '1', "wrmstid", '1') is the right 
> method to insert record in the 
> 'glue' table?
> I am confused by its name - mmAddtoBoth.
> It seems that this method is for adding records to the 2 tables, mdlmst & 
> wrmst.
> Is it so?

        From the method's docstring: "Creates an association in a M-M 
relationship. If the relationship already exists, nothing changes. Otherwise, 
this will ensure that both values exist in their respective tables, and will 
create the entry in the association table."

        So if the records being associated already exist, all that will be 
created is the association. If one or neither of the records exist, they will 
be created, and then the association made. If they both exist and the 
association already exists, nothing at all happens.

> Then why this traceback is encountered:
> (I have now provided in my code the default values, which  while creating 
> bizobj subclasses--
> self.DefaultValues = {'wrmstid':'-1', 'wrmstnm':'w'} )
> ....
> ....  
> File "f:\py\dabo\db\dCursorMixin.py", line 386, in execute
>     raise dException.DBQueryException(errMsg)
> DBQueryException: (1048, "Column 'wrmstid' cannot be null")

        It's difficult to say, since there are two columns named 'wrmstid' in 
your model: the PK of the 'wrmst' table, and the associated key in the 'mdlwr' 
table.

> Maybe, providing pkids of other tables in 'glue' table is a problem.
> Should I provide my code again for your ready reference?

        What was the problem initially is that you were attempting to match on 
PKs that didn't exist in the table. When the framework tried to create those 
records, the NOT NULL restriction caused the insert to fail, and a value of 
None to be returned for the PK of the wrmst table.

        I've made some more improvements in the code today, which might at 
least make for better tracebacks if they don't solve your issues.


-- Ed Leafe



_______________________________________________
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]

Reply via email to