David Chambers avatar David Chambers committed 7488cb5

Added `PROJECT_PATH` to `settings/__init__.py`.

Comments (0)

Files changed (3)

 
         def filesize(path_to_file):
             if not os.path.isabs(path_to_file):
-                project_path = os.path.split(os.path.split(__file__)[0])[0]
-                path_to_file = os.path.join(project_path, path_to_file)
+                path_to_file = os.path.join(PROJECT_PATH, path_to_file)
             try:
                 filesize = os.path.getsize(path_to_file)
             except OSError:

settings/__init__.py

 
 SITE_TITLE = unicode(SITE_TITLE, 'utf-8')
 
-UNIX_PATH_TO_POSTS = PATH_TO_POSTS
-if not UNIX_PATH_TO_POSTS.startswith('/'):
-    UNIX_PATH_TO_POSTS = os.path.join(os.path.split(os.path.split(dirname)[0])[0],
-            *UNIX_PATH_TO_POSTS.split('/'))
-    fragments = []
-    head, tail = os.path.split(UNIX_PATH_TO_POSTS)
-    while tail:
-        fragments.insert(0, tail)
-        head, tail = os.path.split(head)
-    UNIX_PATH_TO_POSTS = u'/%s' % '/'.join(fragments)
-    del fragments, head, tail
-
 DSQ = disqus.DisqusService('1.1')
 try:
     DSQ.login(DISQUS['api_key'])
             break
         FORUM = None
 
+PROJECT_PATH = os.path.split(os.path.split(dirname)[0])[0]
+
+UNIX_PATH_TO_POSTS = PATH_TO_POSTS
+if not UNIX_PATH_TO_POSTS.startswith('/'):
+    UNIX_PATH_TO_POSTS = os.path.join(os.path.split(os.path.split(dirname)[0])[0],
+            *UNIX_PATH_TO_POSTS.split('/'))
+    fragments = []
+    head, tail = os.path.split(UNIX_PATH_TO_POSTS)
+    while tail:
+        fragments.insert(0, tail)
+        head, tail = os.path.split(head)
+    UNIX_PATH_TO_POSTS = u'/%s' % '/'.join(fragments)
+    del fragments, head, tail
+
 del dirname, shortname
     u"\\n<p>Welcome to Mango. ... <strong>Congratulations!</strong></p>"
     """
     if not os.path.isabs(filepath):
-        project_path = os.path.split(os.path.split(__file__)[0])[0]
-        filepath = os.path.join(project_path, filepath)
+        filepath = os.path.join(PROJECT_PATH, filepath)
 
     document, mod_time = cache.get(filepath, (None, None)) # retrieve Document
     if document and mod_time == os.path.getmtime(filepath):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.