On Sunday 13 January 2008 9:31 pm, johnf wrote:
> On Sunday 13 January 2008 07:02:22 pm Adrian Klaver wrote:
> > On Sunday 13 January 2008 6:37 pm, johnf wrote:
> > > On Sunday 13 January 2008 04:18:58 pm Adrian Klaver wrote:
> > > > On Sunday 13 January 2008 1:06 pm, Ed Leafe wrote:
> > > > > On Jan 13, 2008, at 2:59 PM, Adrian Klaver wrote:
> > > > > > Now that John has helped me past the Postgres sequence problem,
> > > > > > I can report on my problems with new(). Below is cut and paste
> > > > > > from my attempts with comments-
> > > > >
> > > > >       Can you re-post after fixing the capitalization problems? It's
> > > > > hard to determine what is and is not due to those errors, and what
> > > > > is an actual problem.
> > > > >
> > > > > -- Ed Leafe
> > > >
> > > > Sorry for the delay. I am up here in Washington State and the weather
> > > > threw an Exception, the Sun came out. Anyway here goes my second
> > > > attempt-
> >
> > <snip>
> >
> > > > New record sequence
> > > >
> > > > bz=self.getBizobj()
> > > > self.new()
> > > > bz.SaveNewUnchanged
> > > > True
> > > > bz.getRecordStatus()
> > > > {}
> > > > # Values below come from Default column settings in Postgres
> > > > database. self.Season.Value
> > > > u'annual'
> > > > self.PlantType.Value
> > > > u'flower'
> > > > self.CategoryType.Value
> > > > u'plant'
> > > > self.CategorySubType.Value
> > > > u'normal'
> > > > self.Common.Value
> > > > u''
> > > > # Enter 'test' into dTextbox RegID Common
> > > > self.Common.Value
> > > > u'test'
> > > > bz.getRecordStatus()
> > > > {'common': (u'', u'test')}
> >
> > <snip>
> >
> > > > One more question. I updated the ClassDesigner but I don't see the
> > > > Keys property in the Property List for a Dropdown List. Is it going
> > > > to be in another revision?
> > > >
> > > >
> > > > Thanks,
> > >
> > > As you discovered Dabo is not aware of Postgres default values.  The
> > > way it can be done in Dabo is as follows in the bizObj:
> > > self.DefaultValues={"PlantType":self._getPlantType}
> >
> > Dabo is aware of the default values. When I call self.new() the Dropdown
> > Lists are populated with the correct default values from Postgres. Those
> > are the self.'RegID'.Value items above.
>
> That does not make sense to me.  The only way that can happen (at least in
> my mind) is if an insert and requery occurred.  I must be missing
> something? I'll test it sometime tomorrow.

I can't help you there, I just know the correct values show up. If I change 
the default then the new default shows up the next time I do self.new().

>
> > The constraint is:
> > insert or update on table "plant1" violates foreign key
> > constraint "plant1_category_fkey"
> > DETAIL:  Key (category_type,category_sub_type)=(,) is not present in
> > table "plant1_category
> > Its a FK between plant1 and plant1_category. It only comes into play
> > because the values for category_type and category_sub_type are not being
> > picked up unless I explicitly select them. The problem isn't the
> > constraint, its doing what it is supposed to, that is prevent entry of
> > record that does not satisfy the FK relationship. The problem is that the
> > values that are necessary to meet that constraint are not being included
> > in the INSERT statement.
> >
> > > Can't help you with the ClassDesigner - that's Ed's domain.
>
> Turn off the constraint.  And check the if the insert/save works.  I'll
> assume that will work because you are getting the  self.LinkField =
> "p_item_no" set - right?.  I'd then try setting the other FK stuff in
> either the berforeSave() or validateField.
The constraint is not the problem. I did as you asked and the INSERT still 
failed. A little background. As originally constructed my bizobj for plant1 
did not have a DefaultValues dictionary. This meant 'empty' fields in the ui 
where passed on as empty strings. I created a DefaultValues dictionary that 
set 'empty' fields in the ui to None and hence to NULL on INSERT.  With the 
empty string version of the bizobj the INSERT on new() succeeded because it 
did not trip my NOT NULL clauses. The None version did trip those clauses and 
the INSERT failed. The problem lies here:

SQL: insert into "public"."plant1" 
("plant_type", "variety", "color", "season",
"category_sub_type", "category_type", "common", "series", "genus", "species")
values ('', '', '', '', '', '', 'test', '', '', '')
# From my original attempt before I created the DefaultValues dict

The new() procedure is not picking up the values in the Dropdown list. 
Everything else that happens is a result of that. The FK failed because the 
values that satisfied where not passed on. The NOT NULL constraints failed 
because NULL values where passed on, in the absence of the actual values 
present in the Dropdown Lists. The errors that I am getting are coming from 
the Postgres database, because the data is not reaching it.   I could strip 
all the constraints from the table and the INSERT even if it succeeded would 
be wrong, because the only value that would make it to the table would be 
that for the common field-'test'. Once I trick the ui into seeing the 
Dropdown List values then everything works. The problem is upstream of the 
database. I don't know how else to explain it or how to make it simpler.

-- 
Adrian Klaver
[EMAIL PROTECTED]


_______________________________________________
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/dabo-users/[EMAIL PROTECTED]

Reply via email to