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-
Setup:
Platform: GTK
Python Version: 2.5.1c1 on linux2
Dabo Version: Version 0.8.3; Revision ~3849
UI Version: 2.8.7.1 on wxGTK (gtk2)
Bizobjs:
createBizobjs(self):
class Publicplant1Bizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "public.plant1"
self.KeyField = "p_item_no"
self.addFrom("public.plant1")
self.addOrderBy("p_item_no")
self.setLimit(10)
self.addField("plant_type")
self.addField("p_item_no")
self.addField("variety")
self.addField("color")
self.addField("season")
self.addField("category_sub_type")
self.addField("category_type")
self.addField("common")
self.addField("series")
self.addField("genus")
self.addField("species")
self.SaveNewUnchanged=True
def validateRecord(self):
"""Returning anything other than an empty string from
this method will prevent the data from being saved.
"""
ret = ""
# Add your business rules here.
return ret
publicplant1Bizobj = Publicplant1Bizobj(self.Connection)
self.addBizobj(publicplant1Bizobj)
class PublicprojectionBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "public.projection"
self.KeyField = "line_id"
self.addFrom("public.projection")
self.addOrderBy("year")
self.addOrderBy("c_id")
self.addField("line_id")
self.addField("c_id")
self.addField("p_item_no")
self.addField("item_key")
self.addField("year")
self.addField("method")
self.addField("sub_method")
self.addField("qty")
self.addField("proj_note")
self.addField("pot_ct")
self.addField("trial")
self.addField("link_key")
self.LinkField = "p_item_no"
self.ParentLinkField = "p_item_no"
self.FillLinkFromParent = True
def validateRecord(self):
"""Returning anything other than an empty string from
this method will prevent the data from being saved.
"""
ret = ""
# Add your business rules here.
return ret
publicprojectionBizobj = PublicprojectionBizobj(self.Connection)
self.addBizobj(publicprojectionBizobj)
publicplant1Bizobj.addChild(publicprojectionBizobj)
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')}
# Save fails because values for fields other than Common are not inserted.
bz.save()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File
"/usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/biz/dBizobj.py",
line 394, in save
raise dException.DBQueryException, e
DBQueryException: 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".
SQL: insert into "public"."plant1"
("plant_type", "variety", "color", "season",
"category_sub_type", "category_type", "common", "series", "genus", "species")
values ('', '', '', '', '', '', 'test', '', '', '')
# I went to form and changed Dropdown List value to another value and then
# back to original value. Doing that made the values show up.
bz.getRecordStatus()
{'plant_type': (u'', u'flower'), 'season': (u'',
u'perennial'), 'category_type':
(u'', u'plant'), 'category_sub_type': (u'', u'normal'), 'common': (u'',
u'test')}
# Save this time was successful.
bz.save()
[('plant1_p_item_no_seq',)]
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,
--
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]