Displaying Values Retrieved from Database

Rich Shepard <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
   Perhaps you folks can point me toward a solution to this problem. As a
newcomer to Python, wxPython, and PySQLite, I have to watch for pitfalls
that trap me so I stop being productive. I'm currently in such a pit and
trying to climb out.

   While I don't know enough to fully implement the Model-View-Controller
pattern, I do want to put all the pysqlite functions in one module that's
separate from the modeling functions' module and all the UI modules.
That's working fine until I get to cleaning up and fully implementing the
sequence of events triggered by a user clicking on the "Open" button to
retrieve and use an existing database. Here's the general sequence:

   The UI module class has a bound method, OnOpenMod(), that calls OpenDB()
in the pysqlite module/class after getting the proper directory and database
name from the user. The general model information is then retrieved from the
appropriate table and displayed in the widgets in the UI class with the
buttons.

   However, each of the other tables in the model database have values that
are entered, displayed, and modified on other UI notebook pages, each in its
own module/class. The problem is letting each of those other modules/classes
know that a database has been opened and the table values are available for
display in each page's widgets. I was pointed to the wx.lib.pubsub() class
(for wxPython), in which the pysqlite module would 'publish' the news that
the database was open and the data available, and each of the UI
module/classes could 'subscribe' to that message topic and retrieve those
data to be set in the page's widgets.

   This is all well and good except for one stumbling block for me: no
examples or demos that show me exactly how to implement this
publish/subscribe system in my application. The API docs are the equivalent
of man pages: great for syntactical reminders but they don't teach the
reader when and how to actually use the tool correctly.

   Does anyone here have an application that uses wx.lib.pubsub(), or have
you an example of another solution to achieve the same goal?

   Opening an existing database and loading table data in the UI is about the
only situation in our application where this issue comes up. Once data are
entered, then the modeling functions take over and crunch the data to
produce results. The key issue I need to resolve is how to inform all the UI
modules that there is an open database so they can get their relevant data
and display it.

TIA,

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.