"Paul McNett" <[EMAIL PROTECTED]> schrieb:
> Sibylle Koczian wrote:
> > as I'm slowly working through this guide, I get the next error: when I try
> > to
> > save a new record for the "hours" table, the error messages are:
> >
> > 1. "Notice" message box:
> > Save Failed:
> >
> > table hours has no column named clientname
> > SQL: insert into "hours"
> > ("clientfk", "notes", "hours", "servicedate", "billed", "clientname")
> > values
> > (1, 'Test', 2.00, '2008-08-16', '', NULL)
> >
> > 2. In the terminal:
> >
> > Dabo Error Log: Sat Aug 16 16:02:14 2008: !!! Data Type Mismatch:
> > field=servicedate. Expecting: <type 'unicode'>; got: <type 'datetime.date'>
> > Dabo Info Log: Sat Aug 16 16:02:14 2008: Key '0' not found
> >
> > Why this? In the database the field has type "date", and only using the
> > Python
> > sqlite3 module I can use a datetime.date object as parameter to an insert
> > statement.
>
> Does the save happen okay, even though you get the message? It is
> probably an erroneous error message.
>
Looking at this a second time I see that the message is printed when the
forms
"new" method is executed, not at saving time. The save happens. But
still I don't
understand it. The control in the form is a dDateTextBox, so shouldn't
it expect
a datetime.date object? Or is this SQLite with its non-standard data
types?
>
> > Message 1 is quite right, but why has such an insert statement been
> > generated?
> > And where can I change it?
>
> NonUpdateFields should be getting automatically set to not include the
> foreign/calculated fields. Obviously it didn't happen in this case.
>
The BizHours code was handwritten (as in the Guide), should
NonUpdateFields be set
anyway? Where and by which magician?
> >
> > The BizObject:
> >
> > #!/usr/bin/env python
> > # -*- coding: utf8 -*-
> > # BizHours.py
> > # Step-By-Step Guide to Dabo Programming
> >
> > import datetime
> > import dabo
> >
> > class BizHours(dabo.biz.dBizobj):
> > def afterInit(self):
> > self.DataSource = "hours"
> > self.KeyField = "pkid"
> > self.addField("hours.pkid")
> > self.addField("hours.clientfk")
> > self.addField("clients.clientname")
> > self.addField("hours.servicedate")
> > self.addField("hours.hours")
> > self.addField("hours.notes")
> > self.addField("hours.billed")
> > self.addFrom("hours")
> > self.addJoin("clients", "hours.clientfk = clients.pkid")
> > self.DefaultValues = {"servicedate": datetime.date.today()}
> >
> > def getClients(self):
> > """Return a 2-tuple of lists of the client names and their keys."""
> > crs = self.getTempCursor()
> > crs.execute("select pkid, clientname from clients order by
> > clientname")
> > ds = crs.getDataSet()
> > # Create the lists
> > names = [rec["clientname"] for rec in ds]
> > keys = [rec["pkid"] for rec in ds]
> > return (names, keys)
> >
> > And the table structure for the "hours" table (ported to SQLite):
> >
> > CREATE TABLE hours (
> > pkid integer PRIMARY KEY,
> > clientfk integer NOT NULL,
> > servicedate date NOT NULL default CURRENT_DATE,
> > hours real(4,2) NOT NULL,
> > notes text(240) NOT NULL,
> > billed tinyint(1) NOT NULL default 0 check(billed in (0, 1))
> > );
> >
> > What is wrong here?
>
> First off, get into the habit of putting your property settings in
> initProperties() instead of afterInit(). Second of all, try explicitly
> setting NonUpdateFields, like:
>
> class BizHours(..):
> ..
> def initProperties(self):
> ..
> self.NonUpdateFields = ["clientname"]
> ..
>
Done and now this works. But shouldn't that be changed in the text of
the Guide?
New problem with the same application: following your mail about the
dSpinner
increment I wanted to put the conversion to Decimal into the
"initProperties"
method of the dSpinner, but put it first into "setProperties" by
mistake. All
this in the ClassDesigners editor. Now I always get "Indented Block
expected"
for the initProperties method (can't cut and paste this, I'm using
Windows at
the moment). I can't see anything wrong with the code in the editor.
What can
I do? And how can I delete methods I shouldn't ever have used?
Sibylle
--
Dr. Sibylle Koczian
Fasanenstrasse 12
D-82293 Mittelstetten
_______________________________________________
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]