diff --git a/VERSION b/VERSION index 6b038b34..1606046b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-05-28 13:08:10) dev +Version 2.00.0 (2012-05-28 13:11:03) dev diff --git a/gluon/shell.py b/gluon/shell.py index 8d534f9f..63706a01 100644 --- a/gluon/shell.py +++ b/gluon/shell.py @@ -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)