Re: Displaying Values Retrieved from Database

[email protected]
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <OF6EAEAFD6.89A0CCBA-ON8525723A.0050012B-8525723A.005070AE@bankofny.com>
Maybe I am naive, but I always think the simplest way is the best. Now
maybe I am not understanding your problem, but unless you need to
dynamically update fields based on someother input, is it not easier to
just query the database when the user goes to a tab, or opens a window?

Just a thought, it reminds me of a quote I found by Brian Kernighan:
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."

I personally adopt this whenever possible, I have found that a small
program that does one thing really well much easier to maintain a large
program that trys do to everything. However you mileage may vary :)

Thanks,

Greg Givler
Information Technology
Lockwood®
10 Valley Stream Parkway
Malvern, PA 19355
Phone: (484) 605-4826
Email: [email protected]


                                                                                                                                           
                      Rich Shepard                                                                                                         
                      <rshepard@appl-ecosys        To:       [email protected]                                                      
                      .com>                        cc:                                                                                     
                      Sent by:                     Subject:  [pysqlite] Displaying Values Retrieved from Database                          
                      pysqlite-bounces@list                                                                                                
                      s.initd.org                                                                                                          
                                                                                                                                           
                                                                                                                                           
                      12/02/2006 12:58 PM                                                                                                  
                      Please respond to                                                                                                    
                      Rich Shepard; Please                                                                                                 
                      respond to "For users                                                                                                
                      of the pysqlite                                                                                                      
                      database module."                                                                                                    
                                                                                                                                           
                                                                                                                                           




   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
_______________________________________________
pysqlite mailing list
pysqlite-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/pysqlite

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please call the help desk at ext 4850
______________________________________________________________________




______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
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.