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():
|
def exec_pythonrc():
|
||||||
pythonrc = os.environ.get('PYTHONSTARTUP')
|
pythonrc = os.environ.get('PYTHONSTARTUP')
|
||||||
if pythonrc and os.path.isfile(pythonrc):
|
if pythonrc and os.path.isfile(pythonrc):
|
||||||
|
def execfile_getlocals(file):
|
||||||
|
execfile(file)
|
||||||
|
return locals()
|
||||||
try:
|
try:
|
||||||
execfile(pythonrc)
|
return execfile_getlocals(pythonrc)
|
||||||
except NameError:
|
except NameError:
|
||||||
pass
|
return dict()
|
||||||
|
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
@@ -200,8 +203,10 @@ def run(
|
|||||||
|
|
||||||
if f:
|
if f:
|
||||||
exec ('print %s()' % f, _env)
|
exec ('print %s()' % f, _env)
|
||||||
elif startfile:
|
return
|
||||||
exec_pythonrc()
|
|
||||||
|
_env.update(exec_pythonrc())
|
||||||
|
if startfile:
|
||||||
try:
|
try:
|
||||||
execfile(startfile, _env)
|
execfile(startfile, _env)
|
||||||
if import_models: BaseAdapter.close_all_instances('commit')
|
if import_models: BaseAdapter.close_all_instances('commit')
|
||||||
@@ -209,7 +214,6 @@ def run(
|
|||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
if import_models: BaseAdapter.close_all_instances('rollback')
|
if import_models: BaseAdapter.close_all_instances('rollback')
|
||||||
elif python_code:
|
elif python_code:
|
||||||
exec_pythonrc()
|
|
||||||
try:
|
try:
|
||||||
exec(python_code, _env)
|
exec(python_code, _env)
|
||||||
if import_models: BaseAdapter.close_all_instances('commit')
|
if import_models: BaseAdapter.close_all_instances('commit')
|
||||||
@@ -253,7 +257,6 @@ def run(
|
|||||||
else:
|
else:
|
||||||
readline.set_completer(rlcompleter.Completer(_env).complete)
|
readline.set_completer(rlcompleter.Completer(_env).complete)
|
||||||
readline.parse_and_bind('tab:complete')
|
readline.parse_and_bind('tab:complete')
|
||||||
exec_pythonrc()
|
|
||||||
code.interact(local=_env)
|
code.interact(local=_env)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user