Allow retrieving the script path
[geekigeeki.git] / geekigeeki.py
index 4ae17b2996fa0da6f7a0b336c7a1df8a69f81e7d..5b26b553da7b344af20ce8d416693d95449f80de 100755 (executable)
@@ -36,6 +36,9 @@ def config_get(key, default=None):
 def script_name():
     return os.environ.get('SCRIPT_NAME', '')
 
+def script_path():
+    return os.path.split(os.environ.get('SCRIPT_FILENAME', ''))[0]
+
 def query_string():
     path_info = os.environ.get('PATH_INFO', '')
     if len(path_info) and path_info[0] == '/':
@@ -418,7 +421,7 @@ class WikiFormatter:
                 macro = globals().get('_macro_' + args[0])
             return macro(*args, **kvargs)
         except Exception, e:
-            msg = cgi.escape(word) + ": " + cgi.escape(e.message)
+            msg = cgi.escape(word) + ": " + cgi.escape(str(e))
             if not self.in_html:
                 msg = '<strong class="error">' + msg + '</strong>'
             return msg
@@ -784,7 +787,7 @@ class Page:
             except OSError, err:
                 if err.errno != errno.ENOENT: raise err
         path = os.path.split(name)[0]
-        if not os.path.exists(path):
+        if path and not os.path.exists(path):
             os.makedirs(path)
         os.rename(tmp_filename, name)