[ckan-dev] Logging in commands question

William Waites ww at styx.org
Wed Apr 6 15:36:58 UTC 2011


* [2011-04-06 17:02:06 +0200] David Read <david.read at okfn.org> écrit:

] In which case, you could try to put the function in a
] separate python file and all clients import that. I think this would
] avoid the problems with ordering of imports and setup of module
] variables that I think are shown in your examples.
] http://effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm

Two problems with this. Firstly the whole point of using getLogger
is to set the logging prefix which should be local to the file 
(actually even better if it is local to the function so you can
really tell where log messages are coming from).

Second problem is if you use global variables like this it gets
extremely side-effecty and difficult to know what is going on. There
is a very good discussion of this phenomenon in the pyramid docs:

http://docs.pylonsproject.org/projects/pyramid/dev/designdefense.html#application-programmers-don-t-control-the-module-scope-codepath-import-time-side-effects-are-evil

Cheers,
-w

-- 
William Waites                <mailto:ww at styx.org>
http://river.styx.org/ww/        <sip:ww at styx.org>
F4B3 39BF E775 CF42 0BAB  3DF0 BE40 A6DF B06F FD45




More information about the ckan-dev mailing list