Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19164 closed Bug (fixed)

Argumented added on the LazySettings.setup method, breaks diffsettings command

Reported by: Mario César Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords:
Cc: Carl Meyer Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Related to ticket #18545, it was added an argument to the setup method of the LazySettings object.

The diffsettings command call settings._setup() to force load all settings and then show to the user.

$ python manage.py diffsettings --traceback
Traceback (most recent call last):
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 252, in execute
    output = self.handle(*args, **options)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 382, in handle
    return self.handle_noargs(**options)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/commands/diffsettings.py", line 19, in handle_noargs
    settings._setup()
TypeError: _setup() takes exactly 2 arguments (1 given)

An option for a fix could be making the argument optional

class LazySettings(LazyObject):
    """
    A lazy proxy for either global Django settings or a custom settings object.
    The user can manually configure settings prior to using them. Otherwise,
    Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
    """
    def _setup(self, name=None):

...

Change History (5)

comment:1 by Mario César, 12 years ago

Has patch: unset
Needs tests: set

comment:2 by Łukasz Rekucki, 12 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Mario César, 12 years ago

I'm proposing a solution → https://github.com/django/django/pull/461

pd: First time trying to get in order to send a patch, really excited :)

comment:4 by Carl Meyer <carl@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 3541a10d492db6d1f509f3a50a024568c16c5229:

Fixed #19164 -- Fixed diffsettings command broken in fix for #18545.

Thanks Mario César for the report and draft patch.

comment:5 by Carl Meyer, 12 years ago

Thanks for the report and patch! I used the basic approach, but there was some trouble with running diffsettings in-process using call_command in the test; it seemed to cause trouble with other tests when the full suite was run. I didn't dig deeply into that, instead I added a diffsettings test in the admin_scripts tests which already have a framework for testing management commands in a subprocess.

Also, the possibility of name being None needed to be accounted for later in _setup where name was used.

Note: See TracTickets for help on using tickets.
Back to Top