Am Donnerstag, 25. September 2008 04:52:14 schrieb Ed Leafe:
> On Sep 24, 2008, at 11:18 AM, Sibylle Koczian wrote:
> > Thank you, now I understand what happens.
>
> OK, before I commit the change, I have a fix that should work. Can
> you test it for me? Change the __saveRow() method of dCursorMixin.py
> to read:
>
> def __saverow(self, row):
> rec = self._records[row]
> recKey = self.pkExpression(rec)
> newrec = kons.CURSOR_TMPKEY_FIELD in rec
> [rest snipped]
>
> With that change, run your app again, and add the manual PK as you
> did before. Let me know if it works correctly or not.
>
Sorry, it doesn't. The beginning of the __saverow() method now looks like
this:
def __saverow(self, row):
rec = self._records[row]
recKey = self.pkExpression(rec)
# Fix Mail Ed Leafe 25.9.08, 04:52:14
newrec = kons.CURSOR_TMPKEY_FIELD in rec
# newrec = self._newRecords.has_key(recKey)
# End of Fix
newPKVal = None
[... snip rest]
I left the debug output statements in. The new assignment for newrec has to
replace the old one, right?
1. No DefaultValue at all for the PK (which seems to mean it defaults to the
empty string):
class BizNum(dabo.biz.dBizobj):
def initProperties(self):
self.DataSource = "numtest"
self.KeyField = "idn"
self.AutoPopulatePK = False
self.SaveNewUnchanged = True
self.UserSQL = """SELECT idn, amount, remark FROM numtest"""
# self.DefaultValues = {"idn": None, "remark": None}
self.DefaultValues["remark"] = None
self.DataStructure = (("idn", "C", True, "numtest", "idn"),
("amount", "N", False, "numtest", "amount"),
("remark", "C", False, "numtest", "remark"))
Button "New" pressed, new PK, new value for "amount", button "Save" pressed:
Status line says "Record 15/15" (that appears when "New" is pressed and
doesn't change afterwards). Debug output and traceback in the terminal:
newrec = False
diff = {'idn': (u'', u'AC5'), 'amount': (Decimal("0.00"), Decimal("23.45"))}
Traceback (most recent call last):
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/ui/uiwx/dControlMixin.py",
line 27, in _onWxHit
self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/ui/uiwx/dPemMixin.py",
line 928, in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/lib/eventMixin.py",
line 92, in raiseEvent
bindingFunction(event)
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/ui/uiwx/dForm.py",
line 682, in onSave
def onSave(self, evt): self.save()
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/ui/uiwx/dForm.py",
line 355, in save
bizobj.saveAll()
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/biz/dBizobj.py",
line 337, in saveAll
startTransaction=False)
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/biz/dBizobj.py",
line 714, in scanChangedRows
self._moveToRowNum(row)
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/biz/dBizobj.py",
line 986, in _moveToRowNum
self._CurrentCursor.moveToRowNum(rownum)
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.4-py2.5.egg/dabo/db/dCursorMixin.py",
line 1592, in moveToRowNum
raise dException.dException, _("Invalid row specified.")
dabo.dException.dException: Invalid row specified.
2. DefaultValue for the PK: None (just changed the comment from the first
assignment to the second):
Button "New" pressed, new PK, new value for "amount", button "Save" pressed:
newrec = False
diff = {'idn': (None, u'AC5'), 'amount': (Decimal("0.00"), Decimal("23.45"))}
Dabo Error Log: Thu Sep 25 14:52:19 2008: Error in scanChangedRows: no such
column: None
SQL: update "numtest" set "idn" = 'AC5', "amount" = 23.45 where "idn"=None
Message box in the application with "Save failed" and the error message.
I don't understand why changing the default value of the PK from the empty
string to None causes such different outcomes. And "no such column: None" in
the error message looks as if a column named "None" had been searched for. In
both cases "newrec = False", which doesn't look good.
Greetings
Sibylle
--
Dr. Sibylle Koczian
_______________________________________________
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]