result of PYTHONSTARTUP scripts execution (export...; def...) is inserted into global() scope of web2py interactive shell, thanks Vlad
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user