On Saturday 24 February 2007 10:01, Ken Dibble wrote:
> Thanks, John.
>
> >Let me say I don't completely understand but I'll give a go by looking at
> >your
> >code.
>
> I'm using MySQL for the database.
>
> I understand about using the underlying biz object code and issuing
> requery() to run queries. I've never been comfortable using a fully
> automated system with data-binding or views because they are only efficient
> with very simple use cases, and my use cases are rarely that simple.
>
> I want to use the Dabo biz object because it knows how to connect to the
> back end and move data back and forth, but I need very fine-grained control
> over everything else.
>
> I'm having trouble explaining the concept of a link table. It's a very
> common database concept. It contains nothing but its own integer pk field,
> and integer foreign key fields that point to other tables. No
> user-serviceable parts inside! I need to be able to get one of those FKs,
> pass it to a routine that will find the matching PK in a record in one of
> those other tables, and return a meaningful value from another field in
> that record. Then I want to display that value on the form. Later, if some
> user changes the meaningful value by picking another one from a list, I'll
> have to call a routine that gets the PK for the new value and inserts that
> into the link table (I'm not trying to model that now, though).
>
> Based on your suggestions, I modified my form. The form runs but I'm now
> getting an error when I press my button. The traceback is at the bottom of
> this message.
>
> Here's the code in my form:
>
> ## *!* ## Dabo Code ID: dButton-dForm
> def onHit(self, evt):
>          biz = self.Form.getBizobj("myAuthors")
>
>          # A spinner, used to select a PK value. Error occurs
>          # here, I think. The dSpinner control certainly does have
>          # a "value" attribute, but the traceback says it doesn't.
>          myPK = self.Form.keySpin.value
>
>          biz.setWhereClause("myAuthors.id = " + str(myPK))
>
>          # The textbox where I want to display the Author.
>          self.Form.thisAuthor.dataSource = "myAuthors"
>
>          self.Form.refresh()
>
> ## *!* ## Dabo Code ID: dForm-top
> def afterInit(self):
>          # This connection has been tested and works fine.
>         
> self.Application.addConnectFile("C:\DaboProjects\MyBooks\mybooks.cnxml")
>
>          conn = self.Application.getConnectionByName("main")
>
>          biz = dabo.biz.dBizobj(conn)
>
>          biz.DataSource = "myAuthors"
>
>          biz.KeyField = "id"
>
>          self.addBizobj(biz)
>
>          biz.addField("author")
>
> Here's the traceback:
>
> Traceback (most recent call last):
>    File "C:\Program Files\Dabo Runtime\dabo\lib\eventMixin.py", line 97, in
> raiseEvent
>    File "c:\docume~1\kend\locals~1\temp\tmphd9tyv.py", line 96, in onHit
> AttributeError: 'dSpinner' object has no attribute 'value'
> Traceback (most recent call last):
>    File "C:\Program Files\Dabo Runtime\dabo\lib\eventMixin.py", line 97, in
> raiseEvent
>    File "C:\Program Files\Dabo Runtime\ide\ClassDesignerFormMixin.py", line
> 127, in onClose
>    File "ClassDesigner.py", line 1867, in designerFormClosing
> AttributeError: 'LayoutSizer' object has no attribute 'Form'
>
> Thanks for your help!
>
> Ken Dibble

Can't stand MySQL have you ever considered Postgres - just kidding!  MySQL is 
just fine.  

Although, last night I was not at my best I think I understand foreign keys 
etc.  But I could still learn more!  But what I was trying to say was you can 
setup bizobjs (datasets) that contains the required fields, define the SQL 
statements and get your results as you expect.  For example:
In a classic one to many situation:
I create a bizobj of a customer table.
 def afterInit(self):
                        self.DataSource = "public.arcust"
                        #self.UserSQL="Select * from public.arcust where custno 
like 'BRS'"
                        self.KeyField = "pkid"
                        self.addFrom("public.arcust")
                        self.addField("arcust.custno")
                        self.addField("arcust.city")
                        self.addField("arcust.company")

For the linked table the bizobj looks like:
 def afterInit(self):
                        self.DataSource = "public.arcontacts"
                        self.KeyField = "pkid"
                        self.LinkField = "fk_arcust"
                        self.addFrom("public.arcontacts")
                        self.addField("lastname")

Note the "self.LinkField".

In your case you would use three bizobj's with two bizobj's with a LinkField.   
Also note I can customize the SQL statement to meet my needs with 
the "UserSQL".  You could create a special bizobj to provide the dataset to 
display and handle the updating by providing a special class.  

One nice thing about using Postgres is they have updateable views.  So you 
could allow Dabo's normal updating routines to update the view.  And a view 
would support your "joins" etc. 

The error messages:
 myPK = self.Form.keySpin.value 
 should that be "Value" and not "value"????
-- 
John Fabiani

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to