Author: jezdez
Date: 2012-02-09 10:56:41 -0800 (Thu, 09 Feb 2012)
New Revision: 17467

Modified:
   django/trunk/django/core/management/__init__.py
   django/trunk/tests/modeltests/user_commands/management/commands/dance.py
Log:
Fixed #10080 -- Slightly extended the fix made in r10401 by also taking command 
line options into account that don't have have a default set. Thanks, Claude 
Paroz.

Modified: django/trunk/django/core/management/__init__.py
===================================================================
--- django/trunk/django/core/management/__init__.py     2012-02-09 18:56:32 UTC 
(rev 17466)
+++ django/trunk/django/core/management/__init__.py     2012-02-09 18:56:41 UTC 
(rev 17467)
@@ -139,9 +139,12 @@
     # when the script runs from the command line, but since call_command can
     # be called programatically, we need to simulate the loading and handling
     # of defaults (see #10080 for details).
-    defaults = dict([(o.dest, o.default)
-                     for o in klass.option_list
-                     if o.default is not NO_DEFAULT])
+    defaults = {}
+    for opt in klass.option_list:
+        if opt.default is NO_DEFAULT:
+            defaults[opt.dest] = None
+        else:
+            defaults[opt.dest] = opt.default
     defaults.update(options)
 
     return klass.execute(*args, **defaults)

Modified: 
django/trunk/tests/modeltests/user_commands/management/commands/dance.py
===================================================================
--- django/trunk/tests/modeltests/user_commands/management/commands/dance.py    
2012-02-09 18:56:32 UTC (rev 17466)
+++ django/trunk/tests/modeltests/user_commands/management/commands/dance.py    
2012-02-09 18:56:41 UTC (rev 17467)
@@ -9,8 +9,10 @@
     requires_model_validation = True
 
     option_list =[
-        make_option("-s", "--style", default="Rock'n'Roll")
+        make_option("-s", "--style", default="Rock'n'Roll"),
+        make_option("-x", "--example")
     ]
 
     def handle(self, *args, **options):
+        example = options["example"]
         self.stdout.write("I don't feel like dancing %s." % options["style"])

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to