main logo
Author: Uwe Grauer <uwemailmeister .AT. googlemail D.OT com>
Subject: Re: [dabo-users] [part 2] a Simple tutorial on bizObjects` - Link
Posted: 2008-08-28 09:26:54
This is the part of the original mail which is missing in the mail archive.
 
johnf wrote:
> -- snip --
>
> Below I have created a small application.  I hate the UI in this example.  So
> would some kind reader post a better UI.  The code creates a one to many
> relation between a customer table and the customer contacts table.  I have
> added several buttons and extra lines to create the child relation and we
> will go over that code in the next installment.  So far all we have done is
> discuss the connection and added a bizObject to our code.  Next time we will
> discuss what steps I took to create the child relation and what Dabo provides
> to help the developer pass SQL statements to the database engine.
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> import os
> import sys
> import dabo
> import dabo.dEvents as dEvents
> import dabo.dException as dException
> dabo.ui.loadUI('wx')
> #the contact table
> class PubliccontactsBizobj(dabo.biz.dBizobj):
>       def afterInit(self):
>               self.DataSource = "public.contacts"
>               self.KeyField = "pkid"
>               self.addFrom("public.contacts")
>               self.addField("firstname")
>               self.addField("phone")
>               self.addField("pkid")
>               self.addField("lastname")
>               self.addField("title")
>               self.addField("custno")
>               self.addField("continent")
>               self.addField("email")
>               self.addField("cont_note")
>               self.addField("fk_arcust")
>               self.NonUpdateFields=["pkid"]
>               self.LinkField = "fk_arcust"
>               self.ParentLinkField ="pkid"
>               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
>
>
>
>
> #the customer table
> class PublicarcustBizobj(dabo.biz.dBizobj):
>       def afterInit(self):
>               self.DataSource = "public.arcustomer"
>               self.addFrom("public.arcustomer")
>               self.KeyField = "pkid"
>               self.addField("czip")
>               self.addField("city")
>               self.addField("pkid")
>               self.addField("state")
>               self.addField("company")
>               self.addField("address1")
>               self.addField("address2")
>               self.addField("country")
>               self.addField("custno")
>
>
> 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
>
> class CustomerPanel(dabo.ui.dPanel):
>       def afterInit(self):
>               self.Sizer=vs=dabo.ui.dSizer('h')
>               gs = dabo.ui.dGridSizer(MaxCols=4,HGap=3, VGap=3)
>               gs.append(dabo.ui.dLabel(self, Caption="Cust #"), halign="right")
>               gs.append(dabo.ui.dTextBox(self, RegID="txtCustomerID",TextLength =
> 10,DataSource ="public.arcustomer", DataField = "custno"), "expand",
> colSpan=3)
>               gs.append(dabo.ui.dLabel(self, Caption="Address"), halign="right")
>               gs.append(dabo.ui.dTextBox(self, RegID="txtAddress1",TextLength =
> 35,DataSource ="public.arcustomer", DataField = "address1"), "expand",
> colSpan=3)
>               gs.append(dabo.ui.dLabel(self, Caption=""), halign="right")
>               gs.append(dabo.ui.dTextBox(self, RegID="txtAddress2",TextLength =
> 35,DataSource ="public.arcustomert", DataField = "address2"), "expand",
> colSpan=3)
>               gs.append(dabo.ui.dLabel(self, Caption="City"), halign="right")
>               gs.append(dabo.ui.dTextBox(self, RegID="txtCity",DataSource
> ="public.arcustomer", DataField = "city"), "expand", colSpan=3)
>               gs.append(dabo.ui.dLabel(self, Caption="Country"), halign="right")
>               gs.append(dabo.ui.dTextBox(self, RegID="txtCountry1",DataSource
> ="public.arcust", DataField = "country"), "expand", colSpan=3)
>               gs.append(dabo.ui.dLabel(self, Caption="State"), halign="right")
>               gs.append(dabo.ui.dTextBox(self,
> RegID="txtSateID",ForceCase='upper',TextLength=2,DataSource
> ="public.arcustomer", DataField = "state"))
>               gs.append(dabo.ui.dLabel(self, Caption="Zip"), halign="right")
>               gs.append(dabo.ui.dTextBox(self, RegID="txtZipD",TextLength=10,DataSource
> ="public.arcustomer", DataField = "czip"), "expand")
>               vs.append(gs,0,'x')
>
>
> class ContactsPanel(dabo.ui.dPanel):
>       def afterInit(self):
>               self.Sizer = dabo.ui.dSizer("v")
>               hs=dabo.ui.dSizer("h")
>               contactGrid = dabo.ui.dGrid(self,RegID="contgridID",AlternateRowColoring
> =True,ColumnCount=6,SelectionMode = "Row",Editable = True,MovableColumns =
> False)
>
> #self.contactGrid.bindEvent(dabo.dEvents.GridCellSelected,self.onGridCellSelected)
>               contactGrid.DataSource = "public.contacts"
>               contactGrid.Columns[0].Caption ="Title"
>               contactGrid.Columns[0].DataField = "title"
>               contactGrid.Columns[1].Caption ="First"
>               contactGrid.Columns[1].DataField = "firstname"
>               contactGrid.Columns[2].Caption ="Last"
>               contactGrid.Columns[2].DataField = "lastname"
>               contactGrid.Columns[3].Caption ="Email"
>               contactGrid.Columns[3].DataField = "email"
>               contactGrid.Columns[4].Caption ="Phone"
>               contactGrid.Columns[4].DataField = "phone"
>               contactGrid.Columns[5].Caption ="Continent"
>               contactGrid.Columns[5].DataField = "continent"
>               hs.append(contactGrid,1,'x')
>               self.Sizer.append(hs,1,'x')
>
>
> class MainForm(dabo.ui.dForm):
>       def afterInit(self):
>               self.Sizer=vs=dabo.ui.dSizer('v')
>               custPanel=CustomerPanel(self)
>               vs.append(custPanel,1,'x')
>               vs.appendSpacer(8)
>               hs= dabo.ui.dSizer('h')
>               hs.append(dabo.ui.dButton(self, Caption="First",OnHit=self.first),0)
>               hs.append(dabo.ui.dButton(self, Caption="Next",OnHit=self.next),0)
>               hs.append(dabo.ui.dButton(self, Caption="Prior",OnHit=self.prior),0)
>               hs.append(dabo.ui.dButton(self, Caption="Last",OnHit=self.last),0)
>               vs.append(hs)
>               vs.appendSpacer(8)
>               contPanel=ContactsPanel(self)
>               vs.append(contPanel,2,'x')
>               self.layout()
>               self. requery()
>
>
>       def first(self,evt):
>               self.super()
>
>       def next(self,evt):
>               self.super()
>
>       def prior(self,evt):
>               self.super()
>
>       def last(self,evt):
>               self.super()
>
>       def createBizobjs(self):
>               self.Application.addConnectFile("tutorial.cnxml")
>               self.Connection = self.Application.getConnectionByName("tutorial")
>
>               publicarcustBizobj = PublicarcustBizobj(self.Connection)
>               self.addBizobj(publicarcustBizobj)
>
>               publiccontactsBizobj = PubliccontactsBizobj(self.Connection)
>               self.addBizobj(publiccontactsBizobj)
>               publicarcustBizobj.addChild(publiccontactsBizobj)
>
>
> if __name__ == "__main__":
>       app = dabo.dApp()
>       app.BasePrefKey = "bizObjTutor"
>       app.setAppInfo("appName", "bizObject Tutorial ")
>       app.MainFormClass = MainForm
>       app.start()
>
> As always if I have errors point them out.  Better yet provide the fix.
 
 
 

Author: Ed Leafe <ed At leafe .DOT com>
Subject: Re: [dabo-users] [part 2] a Simple tutorial on bizObjects` - Link
Posted: 2008-08-28 09:50:37
On Aug 28, 2008, at 8:26 AM, Uwe Grauer wrote:
 
> This is the part of the original mail which is missing in the mail
> archive.
 
        I think your original idea of posting this in the wiki is better than
making them click to read it in the archive.
 
-- Ed Leafe
 
 
 
 
 

Author: Uwe Grauer <uwemailmeister .at. googlemail D.O.T com>
Subject: Re: [dabo-users] [part 2] a Simple tutorial on bizObjects` - Link
Posted: 2008-08-28 10:01:43
Ed Leafe wrote:
> On Aug 28, 2008, at 8:26 AM, Uwe Grauer wrote:
>
>> This is the part of the original mail which is missing in the mail
>> archive.
>
>       I think your original idea of posting this in the wiki is better than
> making them click to read it in the archive.
 
I know!
I would do it on the trac wiki.
But i always end up fighting with the Zwiki formating rules too much.
So i just put a reference to the mail archive on the the wiki instead
of fiddling around too much.
 
Uwe
 
 
 

Author: johnf <jfabiani at yolo .DOT com>
Subject: Re: [dabo-users] [part 2] a Simple tutorial on bizObjects` - Link
Posted: 2008-08-28 10:13:47
On Thursday 28 August 2008 06:50:37 am Ed Leafe wrote:
> On Aug 28, 2008, at 8:26 AM, Uwe Grauer wrote:
> > This is the part of the original mail which is missing in the mail
> > archive.
>
>       I think your original idea of posting this in the wiki is better than
> making them click to read it in the archive.
>
> -- Ed Leafe
 
To be honest I thought you did not feel it was good enough to be posted.  At
the moment I don't know I why I feel that way.  But I think it has something
to do with a off list email.  I guess I can clean it up a little - your
suggestions would be welcome.
 
 
 
--
John Fabiani
 
 

Author: Uwe Grauer <uwemailmeister (at) googlemail .D.OT com>
Subject: Re: [dabo-users] [part 2] a Simple tutorial on bizObjects` - Link
Posted: 2008-08-28 10:34:04
johnf wrote:
> On Thursday 28 August 2008 06:50:37 am Ed Leafe wrote:
>> On Aug 28, 2008, at 8:26 AM, Uwe Grauer wrote:
>>> This is the part of the original mail which is missing in the mail
>>> archive.
>>      I think your original idea of posting this in the wiki is better than
>> making them click to read it in the archive.
>>
>> -- Ed Leafe
>
> To be honest I thought you did not feel it was good enough to be posted.  At
> the moment I don't know I why I feel that way.  But I think it has something
> to do with a off list email.  I guess I can clean it up a little - your
> suggestions would be welcome.
 
There were several new users of Dabo which seem to be using your guide
to get started. So i thought it must be better than not having it at all.
I send at least two people the full part 2 because it was missing in the
archive. That alone is a good reason to have it by reference so people
can use it without asking all the time.
If you feel it isn't good enough we can improve it as soon as it is on
the wiki as a page instead of a reference.
 
Uwe
 
 
 

Author: Ed Leafe <ed /AT/ leafe .D.O.T com>
Subject: Re: [dabo-users] [part 2] a Simple tutorial on bizObjects` - Link
Posted: 2008-08-28 10:37:57
On Aug 28, 2008, at 9:13 AM, johnf wrote:
 
> To be honest I thought you did not feel it was good enough to be
> posted.  At
> the moment I don't know I why I feel that way.  But I think it has
> something
> to do with a off list email.  I guess I can clean it up a little -
> your
> suggestions would be welcome.
 
 
        The whole point of the wiki is that it is a living document. If there
was something that needed fixing/updating, anyone can do it. Links to
email archives do not allow that.
 
-- Ed Leafe
 
 
 
 
 
Powered by Rackspace Cloud Computing
Powered by Rackspace Cloud Computing