As I stated that I am exploring the Class Designer in coming up with
three interface procedures using the spreadsheet function. I am not
tying to find the best way but just using this exercise to learn and the
in my project I will then have the ability to use one of the interfaces
for future sub projects. I also want to explore using Unit Testing and
I thougth I might use the spreadSheet() as a simple starting point. I
have setup the interfaces which are:
1- Directly define the spreadSheet() in the ClassDesigner that is called
in the OnHit event method createSpreadSheet() that makes a single
call to my spreadSheet() to call the spreadsheet in the Class
Designer. !! WORKS WITH OUT A PROBLEM !!
2- Define the spreadSheet() as a method in my customerBizObj.py
class that is located in the biz folder. From within the CD
onHit event callcustomerBizObj.spreadSheet() which is working.
The problem is how to access the dataSet customerBizObj.
3- The last approach is to taking the spreadSheet() in number 1 above
and placing it into a module called spreadsheetLib.py. Then in my CD
onHit event method be able to past the customerBizObj dataSet to my
spreadSheet() function that is in the spreadsheetLib.py and return
value back. I will look at placing this in mainform class.
I am working on number 2 and in the Class Designer my button Create
Spread Sheet Object dCreateCalc:
def onHit(self, evt):
customerBizobj = self.Form.getBizobj("customer")
customerBizobj.spreadSheetBizObj()
This works and I am able to call customerBizobj.spreadSheetBizObj()
by placing a dabo.Trace() at the start of my spreadSheetBizObj() method.
The problem is how to access the dataSet within the spreadSheetBizObj()
method. I tried different ways with the simple error:
custmerBizObj = self.getBizobj("Customer")
AttributeError: 'CustomerBizobj' object has no attribute 'getBizobj'
I just was looking at the code in my Object dCrateCalc and I might be
able to get the dataSet and pass it into my
customerBizobj.spreadSheetBizObj(dataSet).
customerBizobj = self.Form.getBizobj("customer")
customerDataSet =customerBizobj.getDataSet()
customerBizobj.spreadSheetBizObj(customerDataSet)
I will test this but back to the other way using:
customerBizobj = self.Form.getBizobj("customer")
customerBizobj.spreadSheetBizObj()
The code in my customerBizObj.py that is in the biz folder is:
import ooolib
import dabo
class CustomerBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "customer"
self.KeyField = "id"
self.addFrom("customer")
self.addField("valid")
self.addField("id")
self.addField("name")
self.addOrderBy("name")
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
def spreadSheetinBizObj(self):
# Method-1- spreadSheet defined in Class Designer
# Method-2 ** Takes this code and uses it the bizObj
# Method-3- Takes this code and places it in a module to be
# called in a Lib called calcLib.
doc = ooolib.Calc()
custmerBizObj = self.getBizobj("Customer")
localDataSet = custmerBizObj.getDataSet()
# localDataSet = self.PrimaryBizobj.getDataSet()
row_num=1
for row in localDataSet:
col_num=1
for cols in row.keys():
if type(row[cols]) is bool:
columntype='bool'
elif type(row[cols]) is int:
columntype='float'
elif type(row[cols]) is unicode:
columntype='string'
# OK let's write out the data to spreadsheet
doc.set_cell_value(col_num, row_num, columntype,row[cols])
col_num=col_num+1
row_num=row_num+1
# Save the document to the file you want to create.
# You need to change the path to match your environment
doc.save("dabo-example01.ods")
os.popen2('/usr/bin/oocalc dabo-example01.ods')
Any Idea
Bob
_______________________________________________
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/1229272138.6294.78.ca...@sysero-rkm-laptop