Why the new appconfig does not support multiple config files?

127 views
Skip to first unread message

Manuele Pesenti

unread,
Apr 14, 2015, 4:02:53 AM4/14/15
to web2py-d...@googlegroups.com
I started to study this nice new feature introduced in R-2.10 versions... appconfig
I noticed that it's based on SafeConfigParser from the standard python library configparser[1].

I noticed that the read[2] method support multiple files to be passed but the method read_config_ini[3]
does not use this useful feature that could be easily simulated for the json config files with a loop.

If you think it's useful (as I think) I can propose a quite easy patch. What do you think?

Thanks a lot
    Manuele

[1] https://docs.python.org/2/library/configparser.html
[2] https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.read
[3] https://github.com/web2py/web2py/blob/master/gluon/contrib/appconfig.py#L105

Niphlod

unread,
Apr 14, 2015, 6:25:09 AM4/14/15
to web2py-d...@googlegroups.com
how would you merge two files with the same configuration in it ?

Manuele Pesenti

unread,
Apr 14, 2015, 8:17:12 AM4/14/15
to web2py-d...@googlegroups.com
Il 14/04/15 12:25, Niphlod ha scritto:
> how would you merge two files with the same configuration in it ?
well... this is how I patched the appconfig file and loaded from modules
folder of an app:

https://gist.github.com/manuelep/425f0c8a9de6294ad56f

I don't think it has been tested enough :) but is exactly what I thought...

Manuele

Niphlod

unread,
Apr 14, 2015, 3:11:07 PM4/14/15
to web2py-d...@googlegroups.com
this opens up intricacies... the order of loaded files changes how values are eventually overwritten.........
And for take() to have a default defeats the purpose of rapid-failing in case a configuration is missing.

Manuele Pesenti

unread,
Apr 14, 2015, 3:32:27 PM4/14/15
to web2py-d...@googlegroups.com
Il 14/04/15 21:11, Niphlod ha scritto:
> this opens up intricacies... the order of loaded files changes how
> values are eventually overwritten.........
> And for take() to have a default defeats the purpose of rapid-failing
> in case a configuration is missing.
uhm I think I don't understand... can you point me to the defects you
see please?

the order followed depends on the list you pass to the function
AppConfig after a first try to read a default file thet can not exists.

thanks

Manuele

Niphlod

unread,
Apr 14, 2015, 3:47:51 PM4/14/15
to web2py-d...@googlegroups.com

I fear that it'd become something far from the "dead-simple configuration for non-python people" originally thought.
Given your app loading files a,b,c , the non-python person could open file "a", change the "foo" value and see no effects because in "c" there's "foo" too, and that's the one prevailing.

The other argument "against" your snippet is not failing when a configuration value is missing: such need can be accomplished by app code and isn't in the realm of supplying a fast-and-simple way to provide configuration values.

Manuele Pesenti

unread,
Apr 14, 2015, 5:24:22 PM4/14/15
to web2py-d...@googlegroups.com
Il 14/04/15 21:47, Niphlod ha scritto:

I fear that it'd become something far from the "dead-simple configuration for non-python people" originally thought.
Given your app loading files a,b,c , the non-python person could open file "a", change the "foo" value and see no effects because in "c" there's "foo" too, and that's the one prevailing.

The other argument "against" your snippet is not failing when a configuration value is missing: such need can be accomplished by app code and isn't in the realm of supplying a fast-and-simple way to provide configuration values.
ok I got it. Good point.

Thank you Niphlod
Reply all
Reply to author
Forward
0 new messages