In case someone can't see attachment, here's the content of attachment
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

# HG changeset patch
# User Arun K Rajeevan <[email protected]>
# Date 1302552098 -19800
# Node ID fa92d22264a58dd6b232c28b1dd4c78f8ee62c4f
# Parent  d3dc0e7da9aac20f5bab6f2d61afcb78b2444a47
added bpython support

diff -r d3dc0e7da9aa -r fa92d22264a5 gluon/shell.py
--- a/gluon/shell.py Mon Apr 11 09:13:22 2011 -0500
+++ b/gluon/shell.py Tue Apr 12 01:31:38 2011 +0530
@@ -144,6 +144,7 @@
     plain=False,
     import_models=False,
     startfile=None,
+    bpython=False
     ):
     """
     Start interactive shell or run Python script (startfile) in web2py
@@ -203,6 +204,15 @@
             print e.traceback
     else:
         if not plain:
+            if bpython:
+                try:
+                    import bpython
+                    bpython.embed(locals_=_env)
+                    return
+                except:
+                    logger.warning(
+                        'import bpython error; trying ipython...')
+
             try:
                 import IPython
                 # following 2 lines fix a problem with IPython; thanks 
Michael Toomim
@@ -332,6 +342,17 @@
     parser.add_option('-S', '--shell', dest='shell', metavar='APPNAME',
         help='run web2py in interactive shell or IPython(if installed) ' + 
\
             'with specified appname')
+    msg = 'run web2py in interactive shell or bpython (if installed) with'
+    msg += ' specified appname (if app does not exist it will be created).'
+    msg += '\n Use combined with --shell'
+    parser.add_option(
+        '-B',
+        '--bpython',
+        action='store_true',
+        default=False,
+        dest='bpython',
+        help=msg,
+        )
     parser.add_option(
         '-P',
         '--plain',
@@ -369,7 +390,7 @@
         startfile = args[0]
     else:
         startfile = ''
-    run(options.shell, options.plain, startfile=startfile)
+    run(options.shell, options.plain, startfile=startfile, 
bpython=options.bpython)
 
 
 if __name__ == '__main__':
diff -r d3dc0e7da9aa -r fa92d22264a5 gluon/widget.py
--- a/gluon/widget.py Mon Apr 11 09:13:22 2011 -0500
+++ b/gluon/widget.py Tue Apr 12 01:31:38 2011 +0530
@@ -585,6 +585,16 @@
                       metavar='APPNAME',
                       help=msg)
 
+    msg = 'run web2py in interactive shell or bpython (if installed) with'
+    msg += ' specified appname (if app does not exist it will be created).'
+    msg += '\n Use combined with --shell'
+    parser.add_option('-B',
+                      '--bpython',
+                      action='store_true',
+                      default=False,
+                      dest='bpython',
+                      help=msg)
+
     msg = 'only use plain python shell; should be used with --shell option'
     parser.add_option('-P',
                       '--plain',
@@ -790,7 +800,7 @@
     if options.shell:
         if options.args!=None:
             sys.argv[:] = options.args
-        run(options.shell, plain=options.plain,
+        run(options.shell, plain=options.plain, bpython=options.bpython,
             import_models=options.import_models, startfile=options.run)
         return

Reply via email to