Re: [dabo-users] Re : Reference biz objects from ui

Author: Uwe Grauer

Posted: 2007-02-28 at 14:20:32

Dave Nation wrote:

> Thanks for your speedy reply.

>

> I have tried your suggestions and got the following exceptions :

>

> File "C:\THS\orderbook\ui\PagEditProduct.py", line 45, in createItems

> mybiz = self.getBizObject('product')

> AttributeError: 'PagEditProduct' object has no attribute 'getBizObject'

>

>

mybiz = self.Form.getBizobj('product')

> File "C:\THS\orderbook\ui\PagEditProduct.py", line 45, in createItems

> mybiz = self.Form.getBizObject('product')

> AttributeError: 'FrmProduct' object has no attribute 'getBizObject'

>

> My code in biz\Product.py is as follows :-

> def getDepartments(self):

> crs = self.getTempCursor()

> crs.execute('select id, name from department order by name')

> dset = crs.getDataSet()

> names = [rec['name'] for rec in dset]

> ids = [rec['id'] for rec in dset]

> return (names,keys)

>

> My code in ui\PagEditProduct is as follows :-

> mybiz = self.Form.getBizObject('product')

> objectRef = self.addObject(dabo.ui.dListBox, Caption="Department",

> NameBase="DepartmentID", DataSource="Product",

> DataField="DepartmentID", ValueMode='Key',

> Choices = mybiz.getDepartments()[0],

> Keys = mybiz.getDepartments()[1])

>

You can do:

Choices, Keys = mybiz.getDepartments()

Otherwise your query runs twice.

Uwe

©2007 Uwe Grauer