Ticket #14187: bpython-14187.diff

File bpython-14187.diff, 3.4 KB (added by Jeremy Dunck, 14 years ago)

First cut.

  • django/core/management/commands/shell.py

    diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
    index 9616902..236a916 100644
    a b class Command(NoArgsCommand):  
    1111
    1212    requires_model_validation = False
    1313
     14    def ipython(self):
     15        import IPython
     16        # Explicitly pass an empty list as arguments, because otherwise IPython
     17        # would use sys.argv from this script.
     18        shell = IPython.Shell.IPShell(argv=[])
     19        shell.mainloop()
     20
     21    def bpython(self):
     22        import bpython
     23        bpython.embed()
     24
     25    def smart_shell(self):
     26        shells = ('ipython', 'bpython')
     27        for shell in shells:
     28            try:
     29                return getattr(self, shell)()
     30            except ImportError:
     31                pass
     32        raise ImportError
     33
    1434    def handle_noargs(self, **options):
    1535        # XXX: (Temporary) workaround for ticket #1796: force early loading of all
    1636        # models from installed apps.
    class Command(NoArgsCommand):  
    2343            if use_plain:
    2444                # Don't bother loading IPython, because the user wants plain Python.
    2545                raise ImportError
    26             import IPython
    27             # Explicitly pass an empty list as arguments, because otherwise IPython
    28             # would use sys.argv from this script.
    29             shell = IPython.Shell.IPShell(argv=[])
    30             shell.mainloop()
     46            self.smart_shell()
    3147        except ImportError:
    3248            import code
    3349            # Set up a dictionary to serve as the environment for the shell, so
  • docs/man/django-admin.1

    diff --git a/docs/man/django-admin.1 b/docs/man/django-admin.1
    index ce3fdb1..4a459fd 100644
    a b for help on the KEY=val pairs.  
    6565Starts a lightweight Web server for development.
    6666.TP
    6767.BI "shell [" "\-\-plain" "]"
    68 Runs a Python interactive interpreter. Tries to use IPython, if it's available.
     68Runs a Python interactive interpreter. Tries to use IPython or bpython if either is available.
    6969The
    7070.BI \-\-plain
    71 option forces the use of the standard Python interpreter even when IPython is
     71option forces the use of the standard Python interpreter even if IPython or bpython is
    7272installed.
    7373.TP
    7474.BI "sql [" "appname ..." "]"
    Lets you manually add a directory the Python path,  
    131131e.g. "/home/djangoprojects/myproject".
    132132.TP
    133133.I \-\-plain
    134 Use plain Python, not IPython, for the "shell" command.
     134Use plain Python, not IPython or bpython, for the "shell" command.
    135135.TP
    136136.I \-\-noinput
    137137Do not prompt the user for input.
  • docs/ref/django-admin.txt

    diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
    index 67b1b6c..0ed1396 100644
    a b shell  
    623623
    624624Starts the Python interactive interpreter.
    625625
    626 Django will use IPython_, if it's installed. If you have IPython installed and
    627 want to force use of the "plain" Python interpreter, use the ``--plain``
    628 option, like so::
     626Django will use IPython_ or bpython_ if either is installed. If you have a
     627rich shell installed but want to force use of the "plain" Python interpreter,
     628use the ``--plain`` option, like so::
    629629
    630630    django-admin.py shell --plain
    631631
    632632.. _IPython: http://ipython.scipy.org/
     633.. _bpython: http://bpython-interpreter.org/
    633634
    634635sql <appname appname ...>
    635636-------------------------
Back to Top