Changeset 6871
- Timestamp:
- 12/03/07 23:53:33 (9 months ago)
- Files:
-
- django/trunk/django/core/management/__init__.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/__init__.py
r6870 r6871 53 53 {}, {}, ['Command']), 'Command')() 54 54 55 def get_commands( ):55 def get_commands(load_user_commands=True, project_directory=None): 56 56 """ 57 57 Returns a dictionary mapping command names to their callback applications. … … 80 80 if _commands is None: 81 81 _commands = dict([(name, 'django.core') for name in find_commands(__path__[0])]) 82 # Get commands from all installed apps. 83 try: 82 83 if load_user_commands: 84 # Get commands from all installed apps. 84 85 from django.conf import settings 85 apps = settings.INSTALLED_APPS 86 except (AttributeError, ImportError): 87 apps = [] 88 89 for app_name in apps: 90 try: 91 path = find_management_module(app_name) 92 _commands.update(dict([(name, app_name) for name in find_commands(path)])) 93 except ImportError: 94 pass # No management module - ignore this app 95 96 # Try to determine the project directory 97 try: 98 from django.conf import settings 99 project_directory = setup_environ(__import__(settings.SETTINGS_MODULE)) 100 except (AttributeError, ImportError): 101 project_directory = None 86 for app_name in settings.INSTALLED_APPS: 87 try: 88 path = find_management_module(app_name) 89 _commands.update(dict([(name, app_name) for name in find_commands(path)])) 90 except ImportError: 91 pass # No management module -- ignore this app. 102 92 103 93 if project_directory: … … 156 146 self.argv = argv or sys.argv[:] 157 147 self.prog_name = os.path.basename(self.argv[0]) 148 self.project_directory = None 149 self.user_commands = False 158 150 159 151 def main_help_text(self): … … 165 157 usage.append("Type '%s help <subcommand>' for help on a specific subcommand." % self.prog_name) 166 158 usage.append('Available subcommands:') 167 commands = get_commands( ).keys()159 commands = get_commands(self.user_commands, self.project_directory).keys() 168 160 commands.sort() 169 161 for cmd in commands: … … 178 170 """ 179 171 try: 180 app_name = get_commands( )[subcommand]172 app_name = get_commands(self.user_commands, self.project_directory)[subcommand] 181 173 if isinstance(app_name, BaseCommand): 182 174 # If the command is already loaded, use it directly. … … 238 230 def __init__(self, argv, project_directory): 239 231 super(ProjectManagementUtility, self).__init__(argv) 232 self.project_directory = project_directory 233 self.user_commands = True 240 234 241 235 def setup_environ(settings_mod):
