Opened 16 years ago

Last modified 16 years ago

#6017 closed

order of django-admin.py options matters, but shouldn't — at Initial Version

Reported by: Todd O'Bryan Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In ticket #5369, django-admin.py and manage.py are supposed to read all options, looking for --settings and --pythonpath, and then use those two if they're present to access app-supplied commands. The code (which was mine) has a bug, in that options stop getting read as soon as something other than --settings or --pythonpath gets hit.

Without the patch, you currently get: {{{

from django.core.management import LaxOptionParser, get_version
from django.core.management.base import BaseCommand
parser = LaxOptionParser(version=get_version(), option_list=BaseCommand.option_list)
options, args = parser.parse_args('django-admin.py command --option --settings=settingsmodule --pythonpath=/home/user/django-dir'.split())
print options

{'pythonpath': None, 'settings': None}

args

['django-admin.py', 'command', '--settings=settingsmodule', '--pythonpath=/home/user/django-dir']
}}}
where both --pythonpath and --settings get ignored.

With the included patch, you get:{{{

from django.core.management import LaxOptionParser, get_version
from django.core.management.base import BaseCommand
parser = LaxOptionParser(version=get_version(), option_list=BaseCommand.option_list)
options, args = parser.parse_args('django-admin.py command --option --settings=settingsmodule --pythonpath=/home/user/django-dir'.split())
print options

{'pythonpath': '/home/user/django-dir', 'settings': 'settingsmodule'}

args

['django-admin.py', 'command', '--option']
}}}
as desired.

If someone wants me to stick the doctest code somewhere, please tell me where. I think I may need to make a whole new folder, but I don't want to make a mess.

Change History (1)

by Todd O'Bryan, 16 years ago

Attachment: lax-option-parser.patch added
Note: See TracTickets for help on using tickets.
Back to Top