I recently had a similar problem - what I think is missing is a self.requery() in the afterInit of your form. This is because the error is caused by a mismatch between the data type initially in the field (if no requery this is an empty 'unicode' field, with a requery it is whatever is read from the database), and then when the next value goes in it is a date (which doesn't match). Seems to me to be a dabo inconsistency - the initial field type should be set to what is in the data structure if it exists.
Rodgy ----- Original Message ----- From: "johnf" <[email protected]> To: "Dabo Users list" <[email protected]> Sent: Sunday, February 22, 2009 4:44 AM Subject: Re: [dabo-users] dMaskedTextBox issue On Saturday 21 February 2009 09:16:26 am johnf wrote: > > I'm using PostgreSQL database version 8.3.5 and psycopg 2.0.8. > > Here is the Code for the bizobj. I omit some of the fields because they > are > not related to the problem: > > class MaBiz(dabo.biz.dBizobj): > def afterInit(self): > self.DataSource = "public.ma" > self.KeyField = "pkid" > self.addField("ma.pkid") > self.addField("ma.name") > self.addField("ma.vorname") > self.addField("ma.eintritt") > self.addField("ma.gebdat") > self.addFrom("ma") > self.addOrderBy("ma.name") > > self.DefaultValues = None > > The table: > ---------- > > CREATE TABLE ma ( > pkid serial primary key, > name text, > vorname text, > gebdat date, > eintritt date > ); > > Code from main.py: > ------------------ > > #!/usr/bin/env python > # -*- coding: utf-8 -*- > import dabo > import sys > sys.path.append("ui") > import MainForm > dabo.ui.loadUI("wx") > dabo.autoBindEvents = False > > app = dabo.dApp() > app.MainFormClass = MainForm.MainForm > app.NoneDisplay = "" > app.start() > > Relevant code from the panel of the dForm: > --------------------------------- > > class MainPanel(dabo.ui.dPanel): > def afterInit(self): > maBiz = self.Form.getBizobj("public.ma") > self.Sizer = vs = dabo.ui.dSizer('v') > gs = dabo.ui.dGridSizer(MaxRows=6, HGap=4, VGap=3) > gs.append(MaLabel(self, Caption="Name:")) > gs.append(MaTextBox(self, DataSource="public.ma", > DataField="name")) > gs.append(MaLabel(self, Caption="Vorname:")) > gs.append(MaTextBox(self, DataSource="public.ma", > DataField="vorname")) > > gs.append(MaLabel(self, Caption="Eintritt:")) > gs.append(DateBox(self, DataSource="public.ma", > DataField="eintritt")) > gs.append(MaLabel(self, Caption="Geburtsdatum:")) > gs.append(DateBox(self, DataSource="public.ma", > DataField="gebdat")) > > vs.append(gs, layout="expand") > > Code for the class DateBox: > --------------------------- > > class DateBox(dabo.ui.dMaskedTextBox): > > def initProperties(self): > self.Format = "date-eu" > self.ValueMode = "Masked" > > > My system locale is de_DE.utf8. > > If I start the application, two error messages appear in the command line, > one for each field 'eintritt' and 'gebdat' (see my previous post). If I > try > to close the application just after that (without changing any data), I'm > beeing asked whether I want to save the changes. If I answer 'yes', I see > a > popup with "Speichern fehlgeschlagen" (Failed to save), and I see the > following error message in the console: > > Dabo Error Log: Sat Feb 21 18:02:02 2009: Error in scanChangedRows: > > Sorry for the lengthy post, but I didn't want to omit possible relevant > code. > > Best regards > > Peter You have subclassed the dabo UI. I'd first test the code using standard Dabo classes (yes I understand that it should work anyway). I'd start with dDateTextBox and then move on to dMaskTextBox. "Failed to save" suggest that there is something wrong with the either the bizobj description or the data. The fact that it is asking to save may have something to do with dMaskTextBox (because the data is changed from the mask- also there has something to do with the default dates being changed). But before we get to that please test dDateBox. If dDateBox works then test dMaskTexBox with no ValueMode. Let us know the results. -- John Fabiani [excessive quoting removed by server] _______________________________________________ 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/a991902e8dc549b3b6d1b70702674...@roger
