Django

Code

Ticket #11542 (assigned)

Opened 1 year ago

Last modified 6 months ago

Interactive shell is not configurable

Reported by: Seamus Assigned to: Seamus (accepted)
Milestone: Component: Core framework
Version: SVN Keywords: bpython,shell,shell.py,interpreter
Cc: edcrypt, hlecuanda Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Currently when you run manage.py shell Django uses the default python interpreter or Ipython if it's installed. What we need is a setting (or perhaps another parameter?) that allows us to use Bpython ( http://bpython-interpreter.org/ ). IPython is currently hard coded into django, and I think we need more options.

-Seamus

Attachments

bshell.py (419 bytes) - added by Seamus on 09/14/09 10:03:32.
manage.py command
shell.2.py (3.1 kB) - added by Seamus on 09/14/09 13:50:42.
Added commenting, help text, and a fallback to plain if it's an older version of bpython without embed()
shell.py (3.6 kB) - added by Seamus on 09/14/09 14:37:54.
Improvements to the manage.py shell command. (BUGFIXES; IMPROVED COMMENTING; USE THIS ATTACHMENT)
shell.py.diff (5.1 kB) - added by Seamus on 09/14/09 16:16:39.

Change History

07/24/09 09:09:52 changed by romankrv

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Yeah. I propose it in #bpython irc. It will be good idea have flaxable configuration shell.

07/27/09 11:44:35 changed by Seamus

  • owner changed from nobody to Seamus.
  • component changed from Uncategorized to Core framework.
  • stage changed from Unreviewed to Design decision needed.

BPython can now be embedded in Django just like IPython is. When the next version of BPython is released I will post my django patch for bpython.

Currently manage.py tries to import IPython, failing that it uses the default interpreter. My modification would have it first try to use IPython, then BPython, then the default. There would also be a --bpython flag for people who use both. Using this method nobody's default behavior gets messed with -- only people who want to use bpython will be affected.

07/31/09 12:27:54 changed by eliast

Any word on this patch? I'm trying to use bpython from appengine-patch. Thanks!

08/13/09 14:48:05 changed by edcrypt

  • cc set to edcrypt.

09/12/09 14:53:18 changed by ikanobori

Seamus, what is the status on this? Hope you got it to work!

09/14/09 10:03:32 changed by Seamus

  • attachment bshell.py added.

manage.py command

09/14/09 10:10:05 changed by Seamus

  • status changed from new to assigned.

The embedding patch is in bpython, in order to get the latest version install mercurial and run this command:

hg clone https://bitbucket.org/bobf/bpython/

After you get it installed download the attached bshell.py and copy it to your dist-packages/django/core/management/commands folder. Run python manage.py bshell in your project folder to get into the bpython shell. Big thanks to the bpython team for coming up with a great embedding solution.

This bshell.py patch should work in all versions of django. My shell.py patch is also working, I'll complete testing and attach it soon.

09/14/09 10:22:50 changed by Seamus

  • version changed from 1.0 to SVN.
  • milestone set to 1.2.

09/14/09 12:33:18 changed by Seamus

  • needs_docs set to 1.
  • has_patch set to 1.
  • needs_tests set to 1.

09/14/09 12:35:56 changed by Seamus

  • keywords set to bpython,shell,shell.py,interpreter.

09/14/09 13:50:42 changed by Seamus

  • attachment shell.2.py added.

Added commenting, help text, and a fallback to plain if it's an older version of bpython without embed()

09/14/09 14:37:54 changed by Seamus

  • attachment shell.py added.

Improvements to the manage.py shell command. (BUGFIXES; IMPROVED COMMENTING; USE THIS ATTACHMENT)

09/14/09 15:20:58 changed by ikanobori

Thanks Seamus, your patches work fine on my Mac, FreeBSD and Linux system :-)

09/14/09 15:32:58 changed by lvh

Same as ikanobori, but I only tried it on Debian sid. bpython is already awesome, it'd be cool if we could use it instead of ipython with regards to django as an alternative interactive shell.

09/14/09 15:59:17 changed by Seamus

  • needs_tests deleted.
  • milestone deleted.

I've tested it in every situation I can think of. It works with older versions of bpython (IE, it errors out appropriately when specifying --bpython and it falls back to the plain interpreter if it can't find the embed() function). It works with and without ipython installed.

Keep in mind that if you want to test it you should be testing shell.py. bshell was just an early demonstration. Everything seems to work 100%.

09/14/09 16:16:39 changed by Seamus

  • attachment shell.py.diff added.

09/14/09 16:44:30 changed by ikanobori

I have taken some time to make a clean list of things which need to be done to have bpython (http://bpython-interpreter.org) included as a REPL to be used by Django. Seamus has good intentions but might be going over a bit too thin of ice.

bpython 0.9.4, our current version, does not support the embed() method this patch relies on. This is currently only in our mercurial tip, which can be found at http://bitbucket.org/bobf/bpython

Any effort being put into adding bpython embedding to Django should be made after bpython 0.9.5 is released and in repositories.

Furthermore, this patch might be better off being made into a more general patch set which adds support to using any REPL you want (and is also more like the title of this ticket), if it can be embedded. I currently have no idea how to set this up so it is generic enough to be used by Django. I might come back to that on a later time and date.

Seamus has submitted a few files and a diff which adds support for the current embedding functionality of the bpython interpreter.

If there are any questions about the bpython part of this story, feel free to contact me at simon@ikanobori.jp or find me on freenode under the nickname I use here as well.

10/28/09 14:21:54 changed by Seamus

bpython 0.9.5.2 is available at http://bpython-interpreter.org/

Bpython now has full support for embedding, and thus support for Django.

10/28/09 14:27:00 changed by Seamus

  • needs_docs deleted.

11/04/09 05:46:46 changed by becomingGuru

Whats the status of this bug? Is it in for 1.2?

11/20/09 13:02:42 changed by InconV

I am interested in this as well, any news?

01/18/10 18:49:56 changed by hlecuanda

  • cc changed from edcrypt to edcrypt, hlecuanda.

02/10/10 07:28:09 changed by sebastian_noack

See also #12824.


Add/Change #11542 (Interactive shell is not configurable)




Change Properties
Action