Ed Leafe wrote:
> On Jul 13, 2008, at 4:56 PM, Paul McNary wrote:
>
>> Is there any work-around I can use for the problem I'm having in:
>>
>> Dabo Ticket #1159
>
>
> Sorry, I thought Paul was still working with you on this.
>
> I read the ticket, and don't really understand exactly what the
> problem is. Can you describe what steps you are following to create the
> new child record?
>
> -- Ed Leafe
>
>
>
>
>
The following is basically the same as the Ticket report, I just created
a simpler form with more buttons to test theories with:
One to Many:
Primary Biz object being entry fields on main form.
Many being Child Biz Object bound to grid on main form.
Setting the Biz object rules in the Biz objects themselves:
def createBizobjs(self):
class Publiccmpd_HdrBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "public.cmpd_hdr"
self.KeyField = "pkid"
self.addFrom("public.cmpd_hdr")
self.addField("pkid")
self.addField("compoundid")
self.addField("compoundshortdescription")
self.addField("notes")
self.NewChildOnNew=True
self.RequeryChildOnSave=True
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
publiccmpd_hdrBizobj = Publiccmpd_HdrBizobj(self.Connection)
self.addBizobj(publiccmpd_hdrBizobj)
class Publiccmpd_IngredientsBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "public.cmpd_ingredients"
self.KeyField = "itemcompoundid"
self.addFrom("public.cmpd_ingredients")
self.addField("itemid")
self.addField("itemqty")
self.addField("pkid")
self.addField("itemqtyunit")
self.addField("itemdescription")
self.addField("itemcompoundid")
self.addField("itemidtype")
self.addField("itemsequence")
self.LinkField="itemcompoundid"
self.ParentLinkField="compoundid"
self.FillLinkFromParent=True
self.NewRecordOnNewParent=True
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
publiccmpd_ingredientsBizobj =
Publiccmpd_IngredientsBizobj(self.Connection)
self.addBizobj(publiccmpd_ingredientsBizobj)
publiccmpd_hdrBizobj.addChild(publiccmpd_ingredientsBizobj)
-----------------------------------------------------------------------
I let the Biz Objects do their magic and self.Form.new() adds records
to BizObjects, ie: I enter fields on main form and grid has new row
added as expected. I then do a self.Form.save().
It gives me the following traceback:
Traceback (most recent call last):
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/ui/uiwx/dControlMixin.py",
line 26, in _onWxHit
self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/ui/uiwx/dPemMixin.py",
line 915, in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/lib/eventMixin.py",
line 93, in raiseEvent
bindingFunction(event)
File "/tmp/tmpZA2tZY.py", line 395, in onHit
self.Form.save()
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/ui/uiwx/dForm.py",
line 354, in save
bizobj.saveAll()
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/biz/dBizobj.py",
line 333, in saveAll
startTransaction=False)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/biz/dBizobj.py",
line 710, in scanChangedRows
func(*args, **kwargs)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/biz/dBizobj.py",
line 392, in save
child.saveAll(startTransaction=False)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/biz/dBizobj.py",
line 333, in saveAll
startTransaction=False)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/biz/dBizobj.py",
line 708, in scanChangedRows
self._moveToRowNum(row)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/biz/dBizobj.py",
line 984, in _moveToRowNum
self._CurrentCursor.moveToRowNum(rownum)
File
"/usr/lib/python2.4/site-packages/Dabo-0.8.4-py2.4.egg/dabo/db/dCursorMixin.py",
line 1585, in moveToRowNum
raise dException.dException, _("Invalid row specified.")
dabo.dException.dException: Invalid row specified.
---------------------------------------------------------------------------------
This happens whether I have let the Biz Objects create the new grid row
or if I have a button to add the row to the Biz Object:
def onHit(self, evt):
self.Form.new("public.cmpd_ingredients")
---------------------------------------------------------------------------------
However if I add data to the child externally( ie. pgadmin3), requery
fills in the data on the grid. I can change data in that row and
self.Form.save() works as expected. Data is saved.
This only occurs when trying to add a new child row. It happens whether
the grid has any rows or rows that have been added externally.
---------------------------------------------------------------------------------
I know there is a slight language barrier when it comes to properly
referencing things in 3-tier for me. I do understand the basic concepts
of 3-tier but probably do not discuss it correctly yet.
---------------------------------------------------------------------------------
Thanks
Paul McNary
[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/[EMAIL PROTECTED]