Issue95

Title diffsettings
Priority feature Status unread
Superseder Nosy List leif
Assigned To leif Topics Pyre

Created on 2007-03-22.21:54:58 by leif, last changed 2007-03-22.21:54:58 by leif.

Messages
msg302 (view) Author: leif Date: 2007-03-22.21:54:58
While working on Opal/Django, I noticed the 'diffsettings' command:

http://www.djangoproject.com/documentation/django_admin/#diffsettings

Pyre apps could have a similar feature:  dump the differences between the
current configuration and the defaults as a .cfg file.

See also: issue94.


"Talent borrows. Genius steals."

--Oscar Wilde

~~~~

### from django.core.management

def diffsettings():
    """
    Displays differences between the current settings.py and Django's
    default settings. Settings that don't appear in the defaults are
    followed by "###".
    """
    # Inspired by Postfix's "postconf -n".
    from opal.conf import settings, global_settings

    user_settings = _module_to_dict(settings)
    default_settings = _module_to_dict(global_settings)

    output = []
    keys = user_settings.keys()
    keys.sort()
    for key in keys:
        if key not in default_settings:
            output.append("%s = %s  ###" % (key, user_settings[key]))
        elif user_settings[key] != default_settings[key]:
            output.append("%s = %s" % (key, user_settings[key]))
    print '\n'.join(output)
diffsettings.args = ""
History
Date User Action Args
2007-03-22 21:54:58leifcreate