result of PYTHONSTARTUP scripts execution (export...; def...) is inserted into global() scope of web2py interactive shell, thanks Vlad

This commit is contained in:
Massimo Di Pierro
2012-05-28 13:11:12 -05:00
parent 68b5581eb5
commit 8d954bbfc3
2 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-05-28 13:08:10) dev
Version 2.00.0 (2012-05-28 13:11:03) dev
+9 -6
View File
@@ -140,10 +140,13 @@ def env(
def exec_pythonrc():
pythonrc = os.environ.get('PYTHONSTARTUP')
if pythonrc and os.path.isfile(pythonrc):
def execfile_getlocals(file):
execfile(file)
return locals()
try:
execfile(pythonrc)
return execfile_getlocals(pythonrc)
except NameError:
pass
return dict()
def run(
@@ -200,8 +203,10 @@ def run(
if f:
exec ('print %s()' % f, _env)
elif startfile:
exec_pythonrc()
return
_env.update(exec_pythonrc())
if startfile:
try:
execfile(startfile, _env)
if import_models: BaseAdapter.close_all_instances('commit')
@@ -209,7 +214,6 @@ def run(
print traceback.format_exc()
if import_models: BaseAdapter.close_all_instances('rollback')
elif python_code:
exec_pythonrc()
try:
exec(python_code, _env)
if import_models: BaseAdapter.close_all_instances('commit')
@@ -253,7 +257,6 @@ def run(
else:
readline.set_completer(rlcompleter.Completer(_env).complete)
readline.parse_and_bind('tab:complete')
exec_pythonrc()
code.interact(local=_env)