On 1 July 2010 21:05, Cédric Krier <[email protected]> wrote:
> I have updated the wiki page to add load of config.

You seem to have added the two lines:

from trytond.config import CONFIG
CONFIG.load()

But that fails on me the exact same way and when I look at the
trytond.config source code (which is amazingly clean! my hat is off to
you!) then it makes sense, too:

1. The CONFIG object that you call load() on is an instance of the
ConfigManager class.
2. ConfigManager.__init__() sets self.options to a dictionary of default values.
3. ConfigManager.__init__() sets self.configfile = None
4. CONFIG.load() is ConfigManager.load() which, as the first thing it
does, is check if self.configfile is set.
5. Because self.configfile == None, then load() simply returns.
6. The CONFIG object contains only default values.

This works as a temporary fix:

from trytond.config import CONFIG
CONFIG.configfile = "/etc/trytond.conf"  # Bad Hack!
CONFIG.load()

Looking at ConfigManager.parse() leads me to believe that this is the
main function you're usually calling. And it also sets self.configfile
properly.

So I dove right in and created a patch that is doing what you intended
in the wiki:

http://codereview.appspot.com/1692048/diff/1/2

Now using trytond as a module works great with only a CONFIG.load()

:)

Best,
Elver

-- 
[email protected] mailing list

Reply via email to