Am 19.12.2010 18:17, schrieb Sibylle Koczian:
> Done, revision 6271. No change, same errors as before.
With some additional print statements in the
BizCategoriesForRecipe.addLink() method I've seen a little more. Now I
think I know more or less what happens, but I don't know why and it
seems to be wrong:
A new record for the reccat bizobj is created, but the current record
doesn't change: the value of self.Record is still the first child record
belonging to the selected recipe, not the new record. So the assignment
of a new value to self.Record.catid changes this record and not the new
one.
Then the call to self.save() only sends the UPDATE command for this
changed record to the database. So far the new record doesn't seem to exist.
But when the application is closed there is the dialog asking if changes
should be saved - and if I say yes, the application tries to save a new
record with 0 as catid (this fails, as it should). So the new record
obviously exists. But then, why doesn't self.save() send UPDATE _and_
INSERT?
All this if and only if the table reccat has a composite primary key
consisting of the two columns recid and catid.
Platform: GTK
Python Version: 2.6.6 on linux2
Dabo Version: Version 0.9.3; Revision 6271
UI Version: 2.8.11.0 on wxGTK (gtk2)
Here are the details:
def addLink(self, catid):
print "addLink, catid = %d" % catid
if self.hasLink(catid):
raise ValueError("Category %d already linked to this recipe" %
catid)
self.new()
print "New record: %d, %d, %s" % (self.Record.recid, self.Record.catid,
self.Record.descrp)
self.Record.catid = catid
print "New catid: %d, %d, %s" % (self.Record.recid, self.Record.catid,
self.Record.descrp)
self.save()
Example: I start the application and select recipe No. 3, Grilled
Vegetable Sandwiches. Categories 11 (Sandwiches) and 19 (Grilling) are
checked, I check Vegetable Dishes (20).
Output in terminal:
Categories for this recipe: [11, 19]
This is from CklCategories.doUpdate
idx = 58, idxKey = 20
From CklCategories.onHit
Now the output from addLink:
addLink, catid = 20
New record: 3, 11, Sandwiches
*** Here it gets interesting. This is obviously no new record, but
the print statement comes after self.new().
New catid: 3, 20, Sandwiches
Assignment to self.Record - which isn't new.
2010-12-22 16:18:57 - INFO - SQL: BEGIN
2010-12-22 16:18:57 - INFO - SQL: begin
2010-12-22 16:18:57 - INFO - SQL: update "reccat" set "catid" = ? where
"recid"=3 AND "catid"=11 , PARAMS: 20
2010-12-22 16:18:57 - INFO - SQL: COMMIT
2010-12-22 16:18:57 - INFO - SQL: commit
The logging information is consistent with the output before: the
first child record from table reccat is changed.
Now I close the application and the second riddle starts with the
message box asking if I want to save my changes. This shouldn't happen,
because I didn't change anything after the reccat bizobj was last saved.
Answering "yes" I get this:
2010-12-22 16:32:32 - INFO - SQL: BEGIN
2010-12-22 16:32:32 - INFO - SQL: begin
2010-12-22 16:32:32 - INFO - FAILED SQL: insert into "reccat" ("recid",
"catid") values (?,?) , PARAMS: 3, 0
There is the evidence for the creation of the new record.
Greetings
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]