On Friday 12 December 2008 01:55:18 pm Bob Sysero llc Dev wrote:

>     In Method II  I am exploring the business rule or bizobjs
> using both the Class Designer and cxn editor.  I know this
> approach is not the best but my objective is to explore within
> your Class Designer, a way to add a method within the
> customerBizobj.py that was created by cxn editor in my biz dir.
> I am trying to do this completely with the Class Designer and
> editing the customerBizobj.py that will create the customer
> spreadsheet based on my Business Rule in spreadSheetInBiz()
> method.
>
>     Then on the Form that was created by the Class Designer,
> I can have a Button that I can be pressed to create a spread Sheet
> from the method in the customerBizobj.py called spreadSheetInBiz().
> What I am trying to do is learn how to pass a DataSet that I beleave
> was created in the customerBizobj.py under the class AfterInit.
>
>     From the error message:
>
> AttributeError: 'dButton_8999737196751547571' object has no attribute
> 'CustomerBizobj'
>
> I think it is telling me that there is no CustomerBizobj object define
> in the
> scope of my code created by the Class Designer.  What I think is the
> CustomerBizobj is within the framework of dabo if I am using the right
> words.   Johnf said one way is to get the bizobj is to:
>
>     custmerBizObj = self.getBizobj("Customer")
>     custmerBizObj.spreadSheetInBiz()

The above code would work from the mainform class.  Note that I'm 
using "mainform" in lower case to id the name you assigned as the name for 
the mainform.  Often that name is "MainForm" or anything you want it named.  
The key is understanding 'self'.  In what scope are you using 'self' is the 
question.  The above 'self' is the Form (mainform).  However, if you are in 
the button then 'self' is the button.  Therefore, if you want to get to 
a "Form" object/method you have to use 'Form' in the call.  For example if 
you wanted to get the bizobj of 'Customer' from the button you would do
 custmerBizObj = self.Form.getBizobj("Customer")
because the button is a control on the form.
>
> This code code will be placed in my Button and in my CustomerBizobj.py I
> would add a new method.  I think this will work and tonight I will try it.
>
>     def spreadSheetInBiz(self)
>         doc = ooolib.Calc()
>         localDataSet = self.PrimaryBizobj.getDataSet()
>         row_num=1
>         for row in localDataSet:
>            ............. So On ...........
>
If the above code is in the bizobj (that's what I think you are saying) it 
will not work.
In the above case 'self' is the bizobj (Customer).  So "self.PrimaryBizobj" 
has no meaning.  Also, because 'self' is the 'Customer' bizobj you already 
have direct access to the current DataSet for 'Customer'.  At first you would 
think that "self.Form.PrimaryBizobj" would work.  That would be wrong.  The 
bizobj does not know about the 'Form'.  It is not part of the UI (Form in 
this case).  I'm not saying it's not possible for the bizobj to be aware of 
the Form it is just a bad practice.  


>      What I don't understand is back in the days I wrote C code the code
> custmerBizObj.spreadSheetInBiz() would create a compile error on
> the old NCR Tower using Unix.  the self arg would need to be passed
> into the declared procedure.
This is a python thing.  'self' is always passed and you need to do nothing.

>
>     The last Method III is again a way to explore how I can interface a
> module library  that will  contain  central classes and methods to
> interface into the code created by the Class Designer.   What I am trying
> is how to work within the Class Designer code with very specialized code
> that can be swapped in and out based on the package being used on the
> central core design.
If I understand you correctly you can just use "import" statements.  For 
example.

if iWantMelon==True:
    import myMelon
    myMelon.getfood()
elif iWantApple ==True:
    import myApple
    myApple.getfood()
else:
    import myMeat
   myMeat.getfood()

in the class do something like
 def getfood(self):  ## need to pass the self in the declare
     #I need something from the Form.
       self.Form.getsomething() ## where getsomething os a method on the Form.

>
>     What my objected is to learn the inside out at best as I can with
> the Class
> Designer.  This way what I learn my help others learn in using the Dabo
> Class
> Designer as a whole.  Some times I have to fall on my face to learn.

Yes please do write up your experiences.  I'm sure it will help others.
>
> Thank you
> Bob

I think you can get a better understanding of what is happening by using the 
interactive debugger (dShell).  From CD run one of your forms that is 
working.  Then while the form is running type a ctrl-d.  This will bring up a 
window and you can start by typing 'self' and then a return.  On the bottom 
you see the result.  It should be something like "<MainForm (baseclass 
dabo.ui.dForm, id-201)>.  If you assigned a 'RegID' to any of your controls 
type 'self.RegID'  where 'RegID' is the text you assigned to an 
object/control.  Now try 'self.' (notice the period) and wait.  You should 
see a pop-up appear displaying the methods and attributes that are available 
to 'self'.  Have fun!


-- 
John Fabiani


_______________________________________________
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]

Reply via email to