Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5564 -- Fixed handling of the ProjectCommand used by startapp.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 901c3708fb8a2e51bddd37358f8e536282a8c266 1 parent 626a341
Russell Keith-Magee authored September 21, 2007

Showing 1 changed file with 14 additions and 2 deletions. Show diff stats Hide diff stats

  1. 16  django/core/management/__init__.py
16  django/core/management/__init__.py
@@ -65,6 +65,10 @@ def get_commands(load_user_commands=True, project_directory=None):
65 65
     pairs from this dictionary can then be used in calls to 
66 66
     load_command_class(app_name, command_name)
67 67
     
  68
+    If a specific version of a command must be loaded (e.g., with the
  69
+    startapp command), the instantiated module can be placed in the
  70
+    dictionary in place of the application name.
  71
+    
68 72
     The dictionary is cached on the first call, and reused on subsequent
69 73
     calls.
70 74
     """
@@ -109,7 +113,11 @@ def call_command(name, *args, **options):
109 113
     """
110 114
     try:
111 115
         app_name = get_commands()[name]
112  
-        klass = load_command_class(app_name, name)
  116
+        if isinstance(app_name, BaseCommand): 
  117
+            # If the command is already loaded, use it directly.
  118
+            klass = app_name
  119
+        else:
  120
+            klass = load_command_class(app_name, subcommand)
113 121
     except KeyError:
114 122
         raise CommandError, "Unknown command: %r" % name
115 123
     return klass.execute(*args, **options)
@@ -159,7 +167,11 @@ def fetch_command(self, subcommand):
159 167
         """
160 168
         try:
161 169
             app_name = get_commands(self.user_commands, self.project_directory)[subcommand]
162  
-            klass = load_command_class(app_name, subcommand)
  170
+            if isinstance(app_name, BaseCommand): 
  171
+                # If the app_name is already loaded, use it directly.
  172
+                klass = app_name
  173
+            else:
  174
+                klass = load_command_class(app_name, subcommand)
163 175
         except KeyError:
164 176
             sys.stderr.write("Unknown command: %r\nType '%s help' for usage.\n" % (subcommand, self.prog_name))
165 177
             sys.exit(1)

0 notes on commit 901c370

Please sign in to comment.
Something went wrong with that request. Please try again.