Configurable is designed to silently ignore a missing configuration file and
instead revert to a default configuration, which you would specify in the
defaultConfig() method of your subclass. So I assume that it couldn't find
the file, and since you don't have a defaultConfig() method, it just came up
with an empty configuration.
I would suggest making configFilename() return a full path, instead of just
the filename. See if that helps.
On Saturday December 15, 2001 11:23 am, Tim Payne wrote:
> I've been playing around with MiscUtils.Configurable all morning without
> luck, and was wondering if one of you could give me a hand.
> The module I'm trying to use it in wasn't a class, but a collection of
> smaller and unrelated functions I use throughout the rest of my site.
> Looking through the docs and the Configurable module, it looked like I
> needed to subclass it though, so this is what I came up with.
> from MiscUtils.Configurable import Configurable
> class Test(Configurable):
> def configFilename(self):
> return 'News.config'
> def sql(self):
> return self.settings('SQL_Server')
> I had made a file called News.config in the correct folder. It looks
> like this:
> 'SQL_Server': '127.0.0.1',
> Then I used this;
> blah = Test()
> print blah.sql()
> Webkit displayed the following error:
> File "/library/webserver/cgi-
> executables/webware/MiscUtils/Configurable.py", line 62, in setting
> return self.config()[name]
> KeyError: SQL_Server
> If I try self.printConfig() it gives the error ValueError: min() or
> max() arg is an empty sequence
> Any idea what I'm doing wrong? I've tested the config file dictionary
> out separately and it works correctly, so the only way I can see these
> errors happening is if it is accessing the wrong file...
> Webware-discuss mailing list