Browse Source

Explained why os.getcwd is used for path finding

pull/309/head
Armin Ronacher 14 years ago
parent
commit
bb1567dae4
  1. 3
      flask/helpers.py

3
flask/helpers.py

@ -484,6 +484,8 @@ def get_root_path(import_name):
directory = os.path.dirname(sys.modules[import_name].__file__) directory = os.path.dirname(sys.modules[import_name].__file__)
return os.path.abspath(directory) return os.path.abspath(directory)
except AttributeError: 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() return os.getcwd()
@ -499,6 +501,7 @@ def find_package(import_name):
root_mod = sys.modules[import_name.split('.')[0]] root_mod = sys.modules[import_name.split('.')[0]]
package_path = getattr(root_mod, '__file__', None) package_path = getattr(root_mod, '__file__', None)
if package_path is None: if package_path is None:
# support for the interactive python shell
package_path = os.getcwd() package_path = os.getcwd()
else: else:
package_path = os.path.abspath(os.path.dirname(package_path)) package_path = os.path.abspath(os.path.dirname(package_path))

Loading…
Cancel
Save