@@ -391,79 +391,9 @@ def execute(self):
391391 else :
392392 self .fetch_command (subcommand ).run_from_argv (self .argv )
393393
394- def setup_environ (settings_mod , original_settings_path = None ):
395- """
396- Configures the runtime environment. This can also be used by external
397- scripts wanting to set up a similar environment to manage.py.
398- Returns the project directory (assuming the passed settings module is
399- directly in the project directory).
400-
401- The "original_settings_path" parameter is optional, but recommended, since
402- trying to work out the original path from the module can be problematic.
403- """
404- warnings .warn (
405- "The 'setup_environ' function is deprecated, "
406- "you likely need to update your 'manage.py'; "
407- "please see the Django 1.4 release notes "
408- "(https://docs.djangoproject.com/en/dev/releases/1.4/)." ,
409- DeprecationWarning )
410-
411- # Add this project to sys.path so that it's importable in the conventional
412- # way. For example, if this file (manage.py) lives in a directory
413- # "myproject", this code would add "/path/to/myproject" to sys.path.
414- if '__init__.py' in upath (settings_mod .__file__ ):
415- p = os .path .dirname (upath (settings_mod .__file__ ))
416- else :
417- p = upath (settings_mod .__file__ )
418- project_directory , settings_filename = os .path .split (p )
419- if project_directory == os .curdir or not project_directory :
420- project_directory = os .getcwd ()
421- project_name = os .path .basename (project_directory )
422-
423- # Strip filename suffix to get the module name.
424- settings_name = os .path .splitext (settings_filename )[0 ]
425-
426- # Strip $py for Jython compiled files (like settings$py.class)
427- if settings_name .endswith ("$py" ):
428- settings_name = settings_name [:- 3 ]
429-
430- # Set DJANGO_SETTINGS_MODULE appropriately.
431- if original_settings_path :
432- os .environ ['DJANGO_SETTINGS_MODULE' ] = original_settings_path
433- else :
434- # If DJANGO_SETTINGS_MODULE is already set, use it.
435- os .environ ['DJANGO_SETTINGS_MODULE' ] = os .environ .get (
436- 'DJANGO_SETTINGS_MODULE' ,
437- '%s.%s' % (project_name , settings_name )
438- )
439-
440- # Import the project module. We add the parent directory to PYTHONPATH to
441- # avoid some of the path errors new users can have.
442- sys .path .append (os .path .join (project_directory , os .pardir ))
443- import_module (project_name )
444- sys .path .pop ()
445-
446- return project_directory
447-
448394def execute_from_command_line (argv = None ):
449395 """
450396 A simple method that runs a ManagementUtility.
451397 """
452398 utility = ManagementUtility (argv )
453399 utility .execute ()
454-
455- def execute_manager (settings_mod , argv = None ):
456- """
457- Like execute_from_command_line(), but for use by manage.py, a
458- project-specific django-admin.py utility.
459- """
460- warnings .warn (
461- "The 'execute_manager' function is deprecated, "
462- "you likely need to update your 'manage.py'; "
463- "please see the Django 1.4 release notes "
464- "(https://docs.djangoproject.com/en/dev/releases/1.4/)." ,
465- DeprecationWarning )
466-
467- setup_environ (settings_mod )
468- utility = ManagementUtility (argv )
469- utility .execute ()
0 commit comments