Fix STATIC_ROOT determination for standalone js.py usage.

Also, remove import-time dependency on pylons.g.
This commit is contained in:
Max Goodman
2012-02-09 14:09:10 -08:00
parent 93967771ec
commit aaf751ab48

View File

@@ -7,10 +7,15 @@ import json
from r2.lib.translation import iter_langs
if __name__ != "__main__":
from pylons import g, c
STATIC_ROOT = g.paths["static_files"]
try:
from pylons import g, c, config
except ImportError:
STATIC_ROOT = None
else:
STATIC_ROOT = config["pylons.paths"]["static_files"]
# STATIC_ROOT will be None if pylons is uninitialized
if not STATIC_ROOT:
REDDIT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(REDDIT_ROOT, "public")