Django

Code

Changeset 6231

Show
Ignore:
Timestamp:
09/14/07 17:16:14 (1 year ago)
Author:
jacob
Message:

Fixed #3381 - manage.py shell now respects PYTHONSTARTUP/.pythonrc.py.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/commands/shell.py

    r6075 r6231  
     1import os 
    12from django.core.management.base import NoArgsCommand 
    23from optparse import make_option 
     
    4445                readline.set_completer(rlcompleter.Completer(imported_objects).complete) 
    4546                readline.parse_and_bind("tab:complete") 
     47 
     48            # We want to honor both $PYTHONSTARTUP and .pythonrc.py, so follow system 
     49            # conventions and get $PYTHONSTARTUP first then import user. 
     50            if not use_plain:  
     51                pythonrc = os.environ.get("PYTHONSTARTUP")  
     52                if pythonrc and os.path.isfile(pythonrc):  
     53                    try:  
     54                        execfile(pythonrc)  
     55                    except NameError:  
     56                        pass 
     57                # This will import .pythonrc.py as a side-effect 
     58                import user 
    4659            code.interact(local=imported_objects)