I agree with you Nicolas.<div>For now, I'm not sure anyone reported a bug with due to config object being changed. </div><div>Not even sure it's changed anywhere after being filled.</div><div><br></div><div>Yet, the current "config.get" interface is clunky.</div>
<div>You don't know what are the options in which section (without reading all the code).</div><div>Having better organized config object would help documentation first, and understanding the code then.</div><div>I mean:</div>
<div>if (config.general.singlethread) </div><div>is better, IMHO, than </div><div>if (config.get_option("general", "single_thread") == "True")</div><div><br></div><div>For repositories, it could be:</div>
<div>config.repositories["repoNameHere"].nametrans</div><div><br></div><div>For making the documentation, one would grep "config\." and have all in the results, instead of having to understand the variable name and whatever get passed to the different classes.</div>
<div>What do you think ?<br><br><div class="gmail_quote">On Mon, Jan 28, 2013 at 9:39 PM, Nicolas Sebrecht <span dir="ltr"><<a href="mailto:nicolas.s-dev@laposte.net" target="_blank">nicolas.s-dev@laposte.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, Jan 28, 2013 at 10:47:22PM +0400, Eygene Ryabinkin wrote:<br>
> Mon, Jan 28, 2013 at 05:15:53PM +0100, X Ryl wrote:<br>
<br>
</div><div class="im">> > I thought the config was read-only already, and read before any<br>
> > thread is spawn, so I don't get why it would require a singleton<br>
> > class ?<br>
><br>
> My current implementation doesn't singleton'ize the 'config', it<br>
> applies singleton to 'options' that have read/write access.  But, as<br>
> you can see, 'config' variable from offlineimap/init.py is just a<br>
> class that holds the configuration items and they can be modified,<br>
> e.g. by using config.set() method.<br>
><br>
> If we will make, say, 'options' to the global variable, some code can<br>
> unintentionally modify it and this will be very hard to trace, since<br>
> any piece of code can do it: variable is global.<br>
<br>
</div>How some code would modify the global variable 'options'?<br>
<br>
Might be just a matter of opinions but python expects developpers to<br>
know what they do (e.g. attributes of objects are public). Does safety<br>
justify the resulting complexity of the code? Not sure.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Nicolas Sebrecht<br>
</font></span></blockquote></div><br></div>