Re: Data access from multiple code modules

2006-07-13 Thread simon . hibbs
Bruno Desthuilliers wrote: Do you mean the code effectively doing these operations is in the gui ? If yes, it would be better to factor it out IMHO. The GUI has to be able to acces the data object, otherwise how does the user affect any changes to the application data? If I modify a value in

Re: Data access from multiple code modules

2006-07-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: Do you mean the code effectively doing these operations is in the gui ? If yes, it would be better to factor it out IMHO. The GUI has to be able to acces the data object, otherwise how does the user affect any changes to the application

Re: Data access from multiple code modules

2006-07-13 Thread simon . hibbs
Bruno Desthuilliers wrote: Separating operations on data (model/controler) from GUI code (view). The controler(s) have a reference on the model. The views have a reference on the controler(s), and call on the controller to get data to display or act on data. So I instantiate a Model object

Re: Data access from multiple code modules

2006-07-13 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: So I instantiate a Model object that handles all IO to the database. Next I instantiate a Controller object, passing it a reference to the Data/IO model object. Next I instantiate the display panel objects for the GUI, passing them references to the Controller object.

Re: Data access from multiple code modules

2006-07-13 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: Separating operations on data (model/controler) from GUI code (view). The controler(s) have a reference on the model. The views have a reference on the controler(s), and call on the controller to get data to display or act on data. So I

Data access from multiple code modules

2006-07-12 Thread simon . hibbs
Lets say that I have an application consisting of 3 files. A main.py file, gui.py and a data.py which handles persistent data storage. Suppose data.py defines a class 'MyDB' which reads in data from a database, and main.py creates an instance of this object. How does code in gui.py access this

Re: Data access from multiple code modules

2006-07-12 Thread Jeremy Jones
[EMAIL PROTECTED] wrote: Lets say that I have an application consisting of 3 files. A main.py file, gui.py and a data.py which handles persistent data storage. Suppose data.py defines a class 'MyDB' which reads in data from a database, and main.py creates an instance of this object. How does

Re: Data access from multiple code modules

2006-07-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: Lets say that I have an application consisting of 3 files. A main.py file, gui.py and a data.py which handles persistent data storage. Suppose data.py defines a class 'MyDB' which reads in data from a database, and main.py creates an instance of this object. How does

Re: Data access from multiple code modules

2006-07-12 Thread simon . hibbs
Jeremy Jones wrote: What does main.py do? Are you creating an instance of the gui thingy? If so, you could just pass DataObject into your gui thingy either into the constructor or to a setter once you create an instance of it. It's a wxPython app. I created the GUI initialy using wxGlade

Re: Data access from multiple code modules

2006-07-12 Thread Jeremy Jones
[EMAIL PROTECTED] wrote: snip Doh! How simple. Why didn't I think of that? I'm too used to procedural scripts where you'd just put everything in a global data structure. I know this is bad, but it's hard to get out of that mentality. Sounds like you got it. Just pass it on down as needed.

Re: Data access from multiple code modules

2006-07-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] wrote: Jeremy Jones wrote: What does main.py do? Are you creating an instance of the gui thingy? If so, you could just pass DataObject into your gui thingy either into the constructor or to a setter once you create an instance of it. It's a wxPython app. I created the