+from code import InteractiveConsole
- print 'Module readline not available.'
+ print('Module readline not available.')
readline.parse_and_bind('tab: complete')
def my_displayhook(value):
+ global pprint # Needed since Django 1.5, WTF?
if 'DJANGO_SETTINGS_MODULE' in os.environ:
+ from django.db.models import Q
+ from django.conf import settings as S
+ from django.test.client import Client
from django.db.models.loading import get_models
- from django.test.client import Client
from django.test.utils import setup_test_environment, \
teardown_test_environment
- from django.conf import settings as S
class DjangoModels(object):
'Loop through all the models in INSTALLED_APPS and import them.'
+ global get_models # Needed since Django 1.5, WTF?
setattr(self, m.__name__, m)
- setup_test_environment()
+ #setup_test_environment()
S.DEBUG_PROPAGATE_EXCEPTIONS = True
Warning: DEBUG_PROPAGATE_EXCEPTIONS has been set to True.
-# Start an external editor with \e
-# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438813/
-EDITOR = os.environ.get('EDITOR', 'vim')
-from tempfile import mkstemp
-from code import InteractiveConsole
-class EditableBufferInteractiveConsole(InteractiveConsole):
- def __init__(self, *args, **kwargs):
- self.last_buffer = [] # This holds the last executed statement
- InteractiveConsole.__init__(self, *args, **kwargs)
- def runsource(self, source, *args):
- self.last_buffer = [ source.encode('utf-8') ]
- return InteractiveConsole.runsource(self, source, *args)
- def raw_input(self, *args):
- line = InteractiveConsole.raw_input(self, *args)
- fd, tmpfl = mkstemp('.py')
- os.write(fd, b'\n'.join(self.last_buffer))
- os.system('%s %s' % (EDITOR, tmpfl))
- line = open(tmpfl).read()
- lines = line.split( '\n' )
- for i in range(len(lines) - 1): self.push( lines[i] )
-c = EditableBufferInteractiveConsole(locals=locals())
+c = InteractiveConsole(locals=locals())
c.interact(banner=WELCOME)
-# Exit the Python shell on exiting the InteractiveConsole
For some reason, ONLY in Django 1.5 environment, is this needed. I'm probably missing something, but that was the only difference. Same virtualenv, same modules, same everything. The only difference is Django 1.4.5 and Django 1.5. So odd.