durusmail: quixote-users: Config subclassing
Config subclassing
2002-06-20
2002-06-21
2002-06-21
Config subclassing
Mikhail Sobolev
2002-06-20
Having read a small "how-to" manage configs, I tried to do that myself.
The idea was pretty simple:

    -- to add certain parameters
    -- to check that parameters are ok

so the code looked like:

from quixote.config import Config, ConfigError

class OopsConfig (Config):
    config_vars = Config.config_vars + [  ]

    def check_values (self, source):
        if self.myparameter1 is None:
            raise ConfigError ('Must be set', source, 'MYPARAMETER1')

but the code does not really work as expected.  When it tries to
initialize the parameters with default values, it uses quixote.config,
which, obviously, does not have my parameters, so when the `default'
values are read, they are tested to be correct, and here I get my error.

So the question is: what is the correct way for handling additional
configuration parameters?

Thanks,

--
Misha



reply