From bb1567dae48fed50f9742b9136c8bd1b82b7bd55 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 27 Aug 2011 00:42:06 +0200 Subject: [PATCH] Explained why os.getcwd is used for path finding --- flask/helpers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flask/helpers.py b/flask/helpers.py index d8f7ac63..8f2dccf4 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -484,6 +484,8 @@ def get_root_path(import_name): directory = os.path.dirname(sys.modules[import_name].__file__) return os.path.abspath(directory) except AttributeError: + # this is necessary in case we are running from the interactive + # python shell. It will never be used for production code however return os.getcwd() @@ -499,6 +501,7 @@ def find_package(import_name): root_mod = sys.modules[import_name.split('.')[0]] package_path = getattr(root_mod, '__file__', None) if package_path is None: + # support for the interactive python shell package_path = os.getcwd() else: package_path = os.path.abspath(os.path.dirname(package_path))