Problems with new()
Similar to Adrian's issue, I too lose the connection between parent and
child when I click the form's pushbutton and the onHit event triggers
self.Form.new(). The only workaround I could come up with was to add
self.FillLinkFromParent = True to the ChildBizObj. Then, in the
createBizojbs method I had to add the following:
parentBizobj.NewChildOnNew = True
childBizobj.NewRecordOnNewParent = True
This maintains the relationship between and child but it forces the creation
a new and sometimes unwanted child record. Also, I am using MySQL for the
backend and have checked to see if any constraints werer lurking that might
be causing the problem but I can't see any issues there either, but I am far
from an expert on MySQL.
Here is the code for the Bizobjs and the createBizojb method:
class ParentBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "parent"
self.KeyField = "pkid"
self.addFrom("parent")
self.addField("pkid")
self.addField("SSN")
self.addField("Last")
self.addField("First")
class ChildBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "child"
self.KeyField = "pkid"
self.addFrom("child")
self.addField("ChildNo")
self.addField("pkid")
self.addField("Last")
self.addField("First")
self.ParentLinkField = 'pkid'
self.LinkField = "ChildNo"
self.FillLinkFromParent = True
def createBizobjs(self):
self.Application.addConnectFile("ParentChild.cnxml")
self.Connection = self.Application.getConnectionByName("ParentChild")
parentBizobj = ParentBizobj(self.Connection)
self.addBizobj(parentBizobj)
childBizobj = ChildBizobj(self.Connection)
self.addBizobj(childBizobj)
parentBizobj.addChild(childBizobj)
parentBizobj.NewChildOnNew = True
childBizobj.NewRecordOnNewParent = True
Any suggestions?
Steve Rose
On 2/3/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> Send Dabo-users mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://leafe.com/mailman/listinfo/dabo-users
> or, via email, send a message with subject or body 'help' to
> [EMAIL PROTECTED]
>
> You can reach the person managing the list at
> [EMAIL PROTECTED]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Dabo-users digest..."
>
>
> Today's Topics:
>
> 1. New() (Adrian Klaver)
> 2. Re: New() (Ed Leafe)
> 3. Re: New() (Adrian Klaver)
> 4. Re: New() (Ed Leafe)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 02 Feb 2008 22:50:11 +0000
> From: [EMAIL PROTECTED] (Adrian Klaver)
> Subject: [dabo-users] New()
> To: [email protected] (Dabo List)
> Message-ID:
> <
> [EMAIL PROTECTED]
> >
>
>
> I trying to figure out self.Form.new(). I have a button that has an onHit
> event
> with self.Form.new(). When I click on it I get a new parent record. I fill
> in the the fields and save the record, so far so good. At this point I lose
> the connection between the parent and child record. When I use the
> navigation buttons to go back and forward the child records move but the
> parent does not. Also the PK field for the new record remains at -1 even
> though the bizobj has the correct value in the field. Any suggestions
> welcome.
>
> Dabo:
> 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)
>
> Database:
> Postgres 8.2
>
> Bizobj code:
> def 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(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.DefaultValues={'plant_type':None,
> 'season':None,
> 'category_type':None,
> 'category_sub_type':None,
> '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.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 = {'year':None,
> 'c_id':None,
> 'method':None,
> 'p_item_no':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)
>
> --
> Adrian Klaver
> [EMAIL PROTECTED]
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 3 Feb 2008 09:13:38 -0600
> From: Ed Leafe <[EMAIL PROTECTED]>
> Subject: Re: [dabo-users] New()
> To: Dabo Users list <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> On Feb 2, 2008, at 4:50 PM, Adrian Klaver wrote:
>
> > I trying to figure out self.Form.new(). I have a button that has an
> > onHit event
> > with self.Form.new(). When I click on it I get a new parent record.
> > I fill in the the fields and save the record, so far so good. At
> > this point I lose the connection between the parent and child record.
>
> That's odd, as it looks as though you've set up the bizobjs
> correctly. BTW, you don't need to set the ParentLinkField property on
> the child if that is the KeyField in the parent. Dabo assumes that FKs
> link to PKs; you only need to specify that if it links to some other
> non-PK field.
>
> > When I use the navigation buttons to go back and forward the child
> > records move but the parent does not. Also the PK field for the new
> > record remains at -1 even though the bizobj has the correct value in
> > the field. Any suggestions welcome.
>
>
> What is creating the PKs for the new records? I'm assuming that
> you're using PostgreSQL; as far as I know Postgres is working well
> with retrieving auto-generated PKs.
>
> -- Ed Leafe
>
>
>
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 3 Feb 2008 07:40:07 -0800
> From: Adrian Klaver <[EMAIL PROTECTED]>
> Subject: Re: [dabo-users] New()
> To: Dabo Users list <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Sunday 03 February 2008 7:13 am, Ed Leafe wrote:
> > On Feb 2, 2008, at 4:50 PM, Adrian Klaver wrote:
> > > I trying to figure out self.Form.new(). I have a button that has an
> > > onHit event
> > > with self.Form.new(). When I click on it I get a new parent record.
> > > I fill in the the fields and save the record, so far so good. At
> > > this point I lose the connection between the parent and child record.
> >
> > That's odd, as it looks as though you've set up the bizobjs
> > correctly. BTW, you don't need to set the ParentLinkField property on
> > the child if that is the KeyField in the parent. Dabo assumes that FKs
> > link to PKs; you only need to specify that if it links to some other
> > non-PK field.
> >
> > > When I use the navigation buttons to go back and forward the child
> > > records move but the parent does not. Also the PK field for the new
> > > record remains at -1 even though the bizobj has the correct value in
> > > the field. Any suggestions welcome.
> >
> > What is creating the PKs for the new records? I'm assuming that
> > you're using PostgreSQL; as far as I know Postgres is working well
> > with retrieving auto-generated PKs.
> >
> > -- Ed Leafe
>
> The problem boils down to the back end doing the right thing but not the
> front
> end. This led me to do some more digging. Seems I am still having a issue
> with dropdown lists. When I create a new() record I get an error to the
> effect that string value is not in list of choices. As far as I can tell
> that
> is wrong. I have to do further debugging to track down the problem. It
> would
> seem this error may be preventing the GUI from updating properly.
>
> --
> Adrian Klaver
> [EMAIL PROTECTED]
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 3 Feb 2008 10:09:00 -0600
> From: Ed Leafe <[EMAIL PROTECTED]>
> Subject: Re: [dabo-users] New()
> To: Dabo Users list <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> On Feb 3, 2008, at 9:40 AM, Adrian Klaver wrote:
>
> > The problem boils down to the back end doing the right thing but not
> > the front
> > end.
>
> I don't understand. What part of the front end isn't working?
>
> > This led me to do some more digging. Seems I am still having a issue
> > with dropdown lists. When I create a new() record I get an error to
> > the
> > effect that string value is not in list of choices. As far as I can
> > tell that
> > is wrong. I have to do further debugging to track down the problem.
> > It would
> > seem this error may be preventing the GUI from updating properly.
>
> Oh, you didn't mention that you were navigating via dropdown
> lists.
>
> All you need to do is update the Choices property with the new
> value;
> it can be as simple as appending it to Choices as you would append a
> value to any other list, or you could create the choices dynamically
> in a method of your bizobj and return that to the form. This wiki page
> should help:
>
> http://dabodev.com/wiki/HowToPopulateAndUseListControls
>
> -- Ed Leafe
>
>
>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Dabo-users mailing list
> [email protected]
> http://leafe.com/mailman/listinfo/dabo-users
> Searchable Archives: http://leafe.com/archives/search/dabo-users
>
>
> End of Dabo-users Digest, Vol 44, Issue 4
> *****************************************
>
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
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]