Am Montag, 6. Oktober 2008 16:04:55 schrieb Ed Leafe:
> On Oct 6, 2008, at 8:54 AM, Sibylle Koczian wrote:
> >> Ed wrote that validateRecord of the bizobj would be a good place too.
> >
> > I'll try with both of them and look for the differences.
>
> validateRecord() is called automatically from the beforeSave()
> process. It's simply a cleaner way to separate your business logic for
> record validation from other considerations, such as authorization,
> etc., that would typically go in the beforeSave().
>
Ok. Thank you for the explanations. But there is still a problem: if I let the
code in validateRecord() execute for new and changed records alike, that
works. But if I try to do the calculation only for new records, using
IsAdding, then it isn't executed at all. Like this:
def validateRecord(self):
amount = self.Record.amount
rate = self.Record.rate
print "Betrag: %s, Typ: %s" % (amount, type(amount))
print "Stundensatz: %s, Typ: %s" % (rate, type(rate))
hours = amount / rate
print "Stunden: %s, Typ: %s" % (hours, type(hours))
if self.IsAdding:
print "First saving of new record"
self.setFieldVal("hours",
hours.quantize(decimal.Decimal('0.01')))
else:
print "No new record"
New record filled in, button "Save" clicked: the print statements before "if
self.IsAdding:" are executed, and then "No new record". But shouldn't
IsAdding be true at this moment?
BTW I get two Gtk-Warnings now, which is much better, but not quite perfect:
[EMAIL PROTECTED] ~/bin/dabo_sib $ python sqlite_feldtest_2.py
(python:4866): Gtk-WARNING **: gtkwidget.c:4252: no accelerator (113,4)
installed in accel group (0xaea4f00) for GtkImageMenuItem (0xae80498)
(python:4866): Gtk-WARNING **: gtkwidget.c:4252: no accelerator (113,4)
installed in accel group (0xaea4f00) for GtkImageMenuItem (0xae80498)
Happens whenever I start the Dabo editor or my application from the terminal.
Gentoo Linux,
Platform: GTK
Python Version: 2.5.2 on linux2
Dabo Version: Version 0.8.4; Revision ~4555
UI Version: 2.8.7.1 on wxGTK (gtk2)
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]