Opened 11 years ago

Closed 11 years ago

#22697 closed New feature (needsinfo)

Add a public API for extending Settings

Reported by: Ben Davis Owned by: nobody
Component: Uncategorized Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django currently has conf.settings.configure() as a way to configure settings manually, and a typical use case is documented for this:

settings.configure(DEBUG=True, TEMPLATE_DEBUG=True,
    TEMPLATE_DIRS=('/home/web-apps/myapp', '/home/web-apps/base'))

This use case is represented by UserSettingsHolder. However, I think another case where one would want to use Settings, but with some customization. UserSettingsHolder is not well suited to this. I think this could easily be remedied adding a settings_class keyword argument to configure(), which defaults to UserSettingsHolder. Essentially, LazySettings.configure() would look like this:

    def configure(self, default_settings=global_settings, settings_class=None, **options):
        if self._wrapped is not empty:
            raise RuntimeError('Settings already configured.')
        if settings_class is None:
            settings_class = UserSettinsgHolder
        holder = settings_class(default_settings)
        for name, value in options.items():
            setattr(holder, name, value)
        self._wrapped = holder

Change History (2)

comment:1 by Aymeric Augustin, 11 years ago

Can you provide some details about the use case?

comment:2 by Tim Graham, 11 years ago

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top