How about an annotated settings file?

1 view
Skip to first unread message

pbx

unread,
Feb 17, 2006, 11:40:05 AM2/17/06
to Django developers
I made a couple dumb settings.py mistakes this morning (e,g, confusing
DEFAULT_FROM_EMAIL with SERVER_EMAIL).

That got me thinking: How about annotating the default settings file to
describe all available settings? I'm talking about something along the
lines of Apache's default httpd.conf.

I also like the convention used by the bogofilter.cf where default
values are explicitly shown in the config file too.
(http://cvs.sourceforge.net/viewcvs.py/bogofilter/bogofilter/bogofilter.cf.example?view=markup).

I didn't file a ticket yet because this seems like something reasonable
people could disagree on.

So, reasonable people, what do you think?

Jacob Kaplan-Moss

unread,
Feb 17, 2006, 12:15:52 PM2/17/06
to django-d...@googlegroups.com
On Feb 17, 2006, at 10:40 AM, pbx wrote:
> That got me thinking: How about annotating the default settings
> file to
> describe all available settings? I'm talking about something along the
> lines of Apache's default httpd.conf.

You mean something like http://www.djangoproject.com/documentation/
settings/#available-settings ?

Jacob

pbx

unread,
Feb 17, 2006, 1:03:05 PM2/17/06
to Django developers
No -- I mean that the generated settings.py file itself would have
descriptions of each setting, including the defaults. See the
bogofilter link.

pb

ToddG

unread,
Feb 17, 2006, 1:27:34 PM2/17/06
to Django developers
It is a nice touch to have -- Postfix's main conf file is so nicely
commented you can just about completely configure and run it just by
reading the conf file (well, for small setups at least).

Luke Plant

unread,
Feb 17, 2006, 1:35:14 PM2/17/06
to django-d...@googlegroups.com
On Friday 17 February 2006 16:40, pbx wrote:

> That got me thinking: How about annotating the default settings file
> to describe all available settings? I'm talking about something along
> the lines of Apache's default httpd.conf.

<snip>


> So, reasonable people, what do you think?

One of the problems with an annotated conf file is what happens at
upgrade time, when new config options have been added to the system.
In the case of httpd.conf, it's not too bad for me because dconf
(Debian conf system) is great and asks me what to do (i.e. doesn't
overwrite my updated version etc, and even shows me the differences
between the two). But that obviously isn't the case for everyone, and
certainly isn't feasible at all for Django. This means that you'll
still have to go and read the docs for full information, and your fully
annotated version is no longer fully annotated. Even worse are the
cases where a setting is deprecated, or subtleties about its meaning
are changed, but you might go on blindly believing what you read in
your ageing settings.py

Luke

--
"Mistakes: It could be that the purpose of your life is only to serve
as a warning to others." (despair.com)

Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/

pbx

unread,
Feb 17, 2006, 2:59:09 PM2/17/06
to Django developers
Yeah. Postfix also has the nifty "postconf -n" command which shows you
*only* the settings that differ from the defaults (very helpful when
asking someone else for troubleshooting advice).

pbx

unread,
Feb 17, 2006, 5:19:39 PM2/17/06
to Django developers
Luke wrote:

> One of the problems with an annotated conf file is what happens at
> upgrade time, when new config options have been added to the system.
> In the case of httpd.conf, it's not too bad for me because dconf
> (Debian conf system) is great and asks me what to do (i.e. doesn't
> overwrite my updated version etc, and even shows me the differences
> between the two). But that obviously isn't the case for everyone, and
> certainly isn't feasible at all for Django. This means that you'll
> still have to go and read the docs for full information, and your fully
> annotated version is no longer fully annotated. Even worse are the
> cases where a setting is deprecated, or subtleties about its meaning
> are changed, but you might go on blindly believing what you read in
> your ageing settings.py

These are all good points, and are pretty much the objections I
imagined.

I think, though, that upgrades are pretty tricky territory regardless.
There are already comments in settings.py, some of which are surely
going to be made incorrect by a future upgrade. And settings.py isn't
the only place where things need a careful going-over when switching
versions. When I switched from the trunk to magic-removal a few days
ago, settings.py was the least of my worries.

I'm not weddded to this idea by any means, I just wanted to give it a
good airing while we're still here in pre-1.0 land.

pb

Adrian Holovaty

unread,
Feb 17, 2006, 7:31:28 PM2/17/06
to django-d...@googlegroups.com
On 2/17/06, pbx <paul....@gmail.com> wrote:
> That got me thinking: How about annotating the default settings file to
> describe all available settings? I'm talking about something along the
> lines of Apache's default httpd.conf.

Note that django/conf/global_settings.py holds the default values for
every setting, and it's annotated. Of course, you don't edit that
file, so the annotation is mainly for Django developers rather than
Django users. The default settings.py file that's generated for
"django-admin.py startproject" just contains the basic settings that
most people will probably want to change.

So the question is, do we give the generated settings.py file all the
possible settings, or does it continue to have just the settings that
are commonly changed? I really could go either way on this.

Whatever we do, I like the idea Paul mentioned that we could generate
an intelligent "diff" of the settings to find out which settings
aren't default. Very cool!

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Russell Keith-Magee

unread,
Feb 17, 2006, 9:36:14 PM2/17/06
to django-d...@googlegroups.com
On 2/18/06, Adrian Holovaty <holo...@gmail.com> wrote:
> So the question is, do we give the generated settings.py file all the
> possible settings, or does it continue to have just the settings that
> are commonly changed? I really could go either way on this.

Personally, I like the idea of settings.py generating all the possible
settings, but with all the 'not normally required' settings present
(with documentation), but commented out. e.g., the generated
settings.py file would contain sections like:

# E-mail address that error messages come from.
#SERVER_EMAIL = 'root@localhost'

This exposes all settings so that newcomers know what is available for
configuration, shows the default value for those settings,
demonstrates the expected format if the user does want to customize
that setting. The settings that are currently exposed through
settings.py remain uncommented, indicating that user input is probably
required before the application is started for the first time.

Russ Magee %-)

ToddG

unread,
Feb 17, 2006, 10:20:47 PM2/17/06
to Django developers
Those who've also setup Apache a million times will also recognize this
approach...

Maniac

unread,
Feb 18, 2006, 1:16:11 AM2/18/06
to django-d...@googlegroups.com
Adrian Holovaty wrote:

>So the question is, do we give the generated settings.py file all the
>possible settings, or does it continue to have just the settings that
>are commonly changed? I really could go either way on this.
>
>

It's good that current settings.py looks small. This adds to the feeling
of perceived simplicity of Django. It is important because settings.py
is one of the first things that new user sees.

Russell Keith-Magee

unread,
Feb 18, 2006, 4:11:25 AM2/18/06
to django-d...@googlegroups.com
On 2/18/06, Maniac <Man...@softwaremaniacs.org> wrote:

> It's good that current settings.py looks small. This adds to the feeling
> of perceived simplicity of Django. It is important because settings.py
> is one of the first things that new user sees.

How about putting all the essential configuration items at the top of
the generated settings.py, with an obvious 'border' that marks
'optional, but possibly useful configuration options below this line';
e.g.,

...
INSTALLED_APPS = (
)

########################################
# Optional, but possibly useful configuration items follow
########################################

# E-mail address that error messages come from.
#SERVER_EMAIL = 'root@localhost'

...

Russ Magee %-)

Maniac

unread,
Feb 18, 2006, 1:00:28 PM2/18/06
to django-d...@googlegroups.com
Russell Keith-Magee wrote:

>How about putting all the essential configuration items at the top of
>the generated settings.py, with an obvious 'border' that marks
>'optional, but possibly useful configuration options below this line';
>e.g.,
>

This looks reasonable to me... In fact I don't know if it's really
needed when it's documented already. I'm just against unordered
couple-o-dozens-kilobytes config :-)

Reply all
Reply to author
Forward
0 new messages