On Monday 18 February 2008 4:36 pm, Ed Leafe wrote:
> On Feb 18, 2008, at 6:16 PM, Adrian Klaver wrote:
> > The problem is that the transaction does not commit. When I move off
> > the record I get the
> > confirmation dialog asking it I want to save my changes. If I answer
> > yes I get:
> >
> > statement: update "public"."projection" set "sub_method" = 'none',
> > "p_item_no" = 1, "line_id" = 12143, "c_id" = '35RF', "qty" =
> > 10.0000, "trial" = NULL, "link_key" = NULL, "year" = '2008',
> > "proj_note" = NULL, "method" = 'seed', "dabo-tmpKeyField" = NULL,
> > "item_key" = NULL, "pot_ct" = NULL where
> > "public"."projection"."line_id"=-1
> > postgres-production-2008-02-18 16:05:30.828
> >
> > PSTERROR:  column "dabo-tmpKeyField" of relation "projection" does
> > not exist at character 218
> >
> > Note the dabo-tmpKeyField field in the Insert statement.
>
>       That's really odd - I've tested with MySQL and SQLite, and don't see
> this behavior on either. Can you try this: after saving the new
> record, open up a command window and type:
>
> print self.PrimaryBizobj.isAnyChanged()
>
>       If that returns True, then try these two:
>
> biz = self.PrimaryBizobj
> print "NEW", biz._CurrentCursor._getNewRecordDiff(biz.RowNumber)
> print "UPD", biz._CurrentCursor.getRecordStatus(biz.RowNumber)
>
>       Let me know what you get.
>
> -- Ed Leafe

Here is the relevant data. First is traceback from when I attempt the save. 
The field "ts_insert" is in the database but not in the bizobj. This has not 
caused a problem before. Next are the results of the above commands. The 
values shown are coming from the parent bizobj not the child bizobj I am 
actually changing. This may because the child bizobj is actually sending an 
insert statement to the database as shown previously. Lastly are the bizobjs. 
They were initially created with the ClassDesigner, with a few modifications.

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/aklaver/dabo_program/dabo/dabo/ui/uiwx/dForm.py", line 354, in
save
    bizobj.save()
  File "/home/aklaver/dabo_program/dabo/dabo/biz/dBizobj.py", line 373, in 
save
    child.saveAll(startTransaction=False)
  File "/home/aklaver/dabo_program/dabo/dabo/biz/dBizobj.py", line 306, in
saveAll
    startTransaction=False)
  File "/home/aklaver/dabo_program/dabo/dabo/biz/dBizobj.py", line 717, in
scanChangedRows
    func(*args, **kwargs)
  File "/home/aklaver/dabo_program/dabo/dabo/biz/dBizobj.py", line 363, in 
save
    cursor.save()
  File "/home/aklaver/dabo_program/dabo/dabo/db/dCursorMixin.py", line 1168, 
in
save
    saverow(self.RowNumber)
  File "/home/aklaver/dabo_program/dabo/dabo/db/dCursorMixin.py", line 1142, 
in
saverow
    self.__saverow(row)
  File "/home/aklaver/dabo_program/dabo/dabo/db/dCursorMixin.py", line 1269, 
in
__saverow
    self.setFieldVal(fld, val)
  File "/home/aklaver/dabo_program/dabo/dabo/db/dCursorMixin.py", line 900, in
setFieldVal
    raise dException.FieldNotFoundException, ss
FieldNotFoundException: Field 'ts_insert' does not exist in the data set.

NEW {'plant_type': (None, u'flower'), 'p_item_no': (None, 1), 'variety': 
(None,
u''), 'color': (None, None), 'season': (None, u'annual'), 'category_sub_type':
(None, u'normal'), 'category_type': (None, u'plant'), 'common': (None,
u'abutilon ghost bramble'), 'series': (None, u''), 'genus': (None, 
u'abutilon'),
'species': (None, u'vitifolium')}
UPD {}

def createBizobjs(self):
    class Publicplant1Bizobj(dabo.biz.dBizobj):
        def afterInit(self):
            self.DataSource = "public.plant1"
            self.AutoPopulatePK = True
            self.KeyField = "p_item_no"
            self.addFrom("public.plant1")
            self.addOrderBy("p_item_no")
            self.setLimit(None)
            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
            self.RequeryChildOnSave=True
            self.DefaultValues={'plant_type':'herb',
            'season':'annual',
            'category_type':'plant',
            'category_sub_type':'normal',
            'common':None}
        def validateRecord(self):
            """Returning anything other than an empty string from
            this method will prevent the data from being saved.
            """
            
            if len(self.Record.common) == 0:
                print len(self.Record.common)
                ret = 'No empty strings'
            else:
                ret = ""
            # Add your business rules here. 
            return ret
        def validateField(self,fld,val):
            ret = ""
            if fld == 'common' and val == '':
                ret = 'No empty strings'
            return ret

    publicplant1Bizobj = Publicplant1Bizobj(self.Connection)
    self.addBizobj(publicplant1Bizobj)
    
    
    class PublicprojectionBizobj(dabo.biz.dBizobj):
        def afterInit(self):
            self.DataSource = "public.projection"
            self.AutoPopulatePK = True
            self.KeyField = "line_id"
            self.addFrom("public.projection")
            self.addOrderBy("year")
            self.addOrderBy("c_id")
            self.setLimit(None)
            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
            self.SaveNewUnchanged= True
            self.DefaultValues = None
            
        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)

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]

Reply via email to