Changeset 8768
- Timestamp:
- 08/31/08 13:21:06 (4 months ago)
- Files:
-
- django/trunk/django/core/management/__init__.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/__init__.py
r8425 r8768 40 40 part = parts.pop() 41 41 path = None 42 42 43 43 # When using manage.py, the project module is added to the path, 44 # loaded, then removed from the path. This means that 44 # loaded, then removed from the path. This means that 45 45 # testproject.testapp.models can be loaded in future, even if 46 46 # testproject isn't in the path. When looking for the management … … 52 52 if os.path.basename(os.getcwd()) != part: 53 53 raise e 54 54 55 55 while parts: 56 56 part = parts.pop() … … 107 107 project_directory = setup_environ( 108 108 __import__( 109 settings.SETTINGS_MODULE, {}, {}, 109 settings.SETTINGS_MODULE, {}, {}, 110 110 (settings.SETTINGS_MODULE.split(".")[-1],) 111 ) 111 ), settings.SETTINGS_MODULE 112 112 ) 113 113 except (AttributeError, EnvironmentError, ImportError): … … 167 167 def error(self, msg): 168 168 pass 169 169 170 170 def print_help(self): 171 171 """Output nothing. 172 172 173 173 The lax options are included in the normal option parser, so under 174 174 normal usage, we don't need to print the lax options. 175 175 """ 176 176 pass 177 177 178 178 def print_lax_help(self): 179 179 """Output the basic options available to every command. 180 180 181 181 This just redirects to the default print_help() behaviour. 182 182 """ 183 183 OptionParser.print_help(self) 184 184 185 185 def _process_args(self, largs, rargs, values): 186 186 """ 187 187 Overrides OptionParser._process_args to exclusively handle default 188 options and ignore args and other options. 189 190 This overrides the behavior of the super class, which stop parsing 188 options and ignore args and other options. 189 190 This overrides the behavior of the super class, which stop parsing 191 191 at the first unrecognized option. 192 192 """ … … 263 263 # must be processed early. 264 264 parser = LaxOptionParser(usage="%prog subcommand [options] [args]", 265 version=get_version(), 265 version=get_version(), 266 266 option_list=BaseCommand.option_list) 267 267 try: … … 295 295 self.fetch_command(subcommand).run_from_argv(self.argv) 296 296 297 def setup_environ(settings_mod ):297 def setup_environ(settings_mod, original_settings_path=None): 298 298 """ 299 299 Configures the runtime environment. This can also be used by external … … 301 301 Returns the project directory (assuming the passed settings module is 302 302 directly in the project directory). 303 304 The "original_settings_path" parameter is optional, but recommended, since 305 trying to work out the original path from the module can be problematic. 303 306 """ 304 307 # Add this project to sys.path so that it's importable in the conventional … … 315 318 316 319 # Set DJANGO_SETTINGS_MODULE appropriately. 317 os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name) 320 if original_settings_path: 321 os.environ['DJANGO_SETTINGS_MODULE'] = original_settings_path 322 else: 323 os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name) 318 324 return project_directory 319 325
