From aaf751ab48ac94e72bb92d11a13cc43aa0cc9c46 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Thu, 9 Feb 2012 14:09:10 -0800 Subject: [PATCH] Fix STATIC_ROOT determination for standalone js.py usage. Also, remove import-time dependency on pylons.g. --- r2/r2/lib/js.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/r2/r2/lib/js.py b/r2/r2/lib/js.py index dda0f761d..9ac4039f0 100755 --- a/r2/r2/lib/js.py +++ b/r2/r2/lib/js.py @@ -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")