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 03:02 pm, Rich Shepard wrote: > On Mon, 27 Nov 2006, Adrian Klaver wrote: > > Try- > > print 'dbFileName = 'config.projname+ config.dbFileName > > My guess it is an order of execution problem. projname starts out as ' ' > > and that is what you are getting- ' '+'db'=' .db' You need to track down > > when a value is assigned to projname and call dbFileName after that. > > Adrian, > > The value is assigned to config.projname in functions.newFile(). First > the pwd and filename are assigned by the user. Nothing is done to > dbFileName until immediately after that. The functions.newFile() is: > > def newFile(self): > """ Create a new project database file and open it.""" > wd = wx.DirDialog(None, "Choose a default directory:", defaultPath=".", > style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON) > if wd.ShowModal() == wx.ID_OK: > config.dirname = wd.GetPath() > wd.Destroy() > ted = wx.TextEntryDialog(self, "Enter the project name", "New Project > Name", "", style=wx.RAISED_BORDER|wx.OK|wx.CANCEL) if ted.ShowModal() == > wx.ID_OK: > config.projname = ted.GetValue() > config.dbFileName = ted.GetValue() + '.db' > ted.Destroy() > > Originally, the next-to-last line wasn't there, and config.py did the > assignment of projname + '.db'. > > Rich With out seeing the whole class structure, here is my best guess- When you call def OnNewMod() you get the names config.dirname and config.projname from def newFile(). Until you made the change, config.dbFileName was only defined in config.py. Unless you are writing to config.py and changing the values for dirname and projname their values are set to ' '. So when the app goes back to the first definition of config.dbFileName it can find it does what is it told which is concatenate projname+'.db'. In config.py that means ' '+'.db'. The solutions are either to update config.py as new entries are made, your fix or the fix I proposed. -- Adrian Klaver [email protected]