#22697 closed New feature (needsinfo)

Add a public API for extending Settings

Reported by: bendavis78 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


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 Changed 16 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Can you provide some details about the use case?

comment:2 Changed 16 months ago by timo

  • Resolution set to needsinfo
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top