Re: A Trivial Python Error

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
On Monday 27 November 2006 05:16 pm, Rich Shepard wrote:
> On Mon, 27 Nov 2006, Adrian Klaver wrote:
> > I may not be explaining it well , but when you are doing the above you
> > are only changing the name in the namespace of newFile(). Unless there is
> > another part that I am not seeing the name change will not propagate back
> > to config.py. newFile() is called by OnNewMod() so OnNewMod() sees the
> > changes from newFile() only.
>
>    Ah! So comes the dawn. Yes, it all makes perfect sense now.
>
>    Since I want the values for the three variables (directory, file and
> database names) to be globally visible -- which is why they're in a
> separate module imported by all the others -- how should I pass the values
> to the config.py namespace? This, of course, needs to be done each time the
> model is run and a database file created or opened.
>
> Many thanks,
>
> Rich
I don't know how config.py is structured. But my inclination would be create a 
fileConfig class in it with an __init__ that takes as its attributes the pwd 
and projname. You would create an instance of this class in newFile() and 
pass it the attributes from wd.GetPath() and  ted.GetValue(). This instance 
would then be passed to OnNewMod() and the attributes would carry over. This 
solves the problem of what to do if more than person writes to config.py at 
the same time. A class approach would give each call to the class a custom 
set of attributes. This is not tested and runs the risk of different parts of 
the app calling newFile() and getting the same class instance when in fact 
they may need different instances.

-- 
Adrian Klaver	
[email protected]
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.