diff options
Diffstat (limited to 'src/mailman/commands')
| -rw-r--r-- | src/mailman/commands/cli_withlist.py | 31 | ||||
| -rw-r--r-- | src/mailman/commands/docs/withlist.rst | 19 |
2 files changed, 44 insertions, 6 deletions
diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py index 61e1bec7c..7bf7c4384 100644 --- a/src/mailman/commands/cli_withlist.py +++ b/src/mailman/commands/cli_withlist.py @@ -27,7 +27,9 @@ __all__ = [ import re +import sys +from lazr.config import as_boolean from zope.component import getUtility from zope.interface import implements @@ -149,7 +151,30 @@ class Withlist: abort=config.db.abort, config=config, ) - interact(upframe=False, banner=banner, overrides=overrides) + banner = config.shell.banner + '\n' + banner + if as_boolean(config.shell.use_ipython): + self._start_ipython(overrides, banner) + else: + self._start_python(overrides, banner) + + def _start_ipython(self, overrides, banner): + try: + from IPython.frontend.terminal.embed import InteractiveShellEmbed + ipshell = InteractiveShellEmbed(banner1=banner, user_ns=overrides) + ipshell() + except ImportError: + print _('ipython is not available, set use_ipython to no') + + def _start_python(self, overrides, banner): + # Set the tab completion. + try: + import readline, rlcompleter + readline.parse_and_bind('tab: complete') + except ImportError: + pass + else: + sys.ps1 = config.shell.prompt + ' ' + interact(upframe=False, banner=banner, overrides=overrides) def _details(self): """Print detailed usage.""" @@ -214,9 +239,9 @@ and run this from the command line: % bin/mailman withlist -r change mylist@example.com 'My List'""") - + class Shell(Withlist): """An alias for `withlist`.""" - + name = 'shell' diff --git a/src/mailman/commands/docs/withlist.rst b/src/mailman/commands/docs/withlist.rst index 7632c726a..f00208490 100644 --- a/src/mailman/commands/docs/withlist.rst +++ b/src/mailman/commands/docs/withlist.rst @@ -119,7 +119,20 @@ You also get an error if no mailing list is named. --run requires a mailing list name -Clean up -======== +IPython +======= - >>> sys.path = old_path +You can use `IPython`_ as the interactive shell by changing certain +configuration variables in the `[shell]` section of your `mailman.cfg` file. +Set `use_ipython` to "yes" to switch to IPython, which must be installed on +your system. + +Other configuration variables in the `[shell]` section can be used to +configure other aspects of the interactive shell. You can change both the +prompt and the banner. + + +.. Clean up + >>> sys.path = old_path + +.. _`IPython`: http://ipython.org/ |
