From: Bernie Innocenti Date: Wed, 19 Aug 2009 09:20:37 +0000 (+0200) Subject: chdir into data_dir to simplify a few things X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=68d4178e022cfe5946b7a574fb20aaae41d98f14;p=geekigeeki.git chdir into data_dir to simplify a few things --- diff --git a/geekigeeki.py b/geekigeeki.py index ca62bed..f906c07 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -237,7 +237,6 @@ def link_inline(name, descr=None, kvargs={}): % (url, url, name) def link_inline_glob(pattern, descr=None, kvargs={}): - os.chdir(config_get('data_dir', 'data')) s = '' for name in glob.glob(pattern): s += link_inline(name, descr, kvargs) @@ -341,7 +340,7 @@ def page_list(dirname=None, search_re=None): if search_re is None: # FIXME: WikiWord is too restrictive now! search_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$") - return sorted(filter(search_re.match, os.listdir(dirname or config_get('data_dir', 'data')))) + return sorted(filter(search_re.match, os.listdir(dirname or '.'))) def send_footer(mod_string=None): if config_get('debug_cgi', False): @@ -633,10 +632,10 @@ class Page: return re.sub('([a-z])([A-Z])', r'\1 \2', self.page_name) def _filename(self): - return os.path.join(config_get('data_dir', 'data'), self.page_name) + return self.page_name def _tmp_filename(self): - return os.path.join(config_get('data_dir', 'data'), ('#' + self.page_name.replace('/','_') + '.' + str(os.getpid()) + '#')) + return self.page_name + '.tmp' + str(os.getpid()) + '#' def exists(self): try: @@ -809,7 +808,7 @@ class Page: import subprocess cmd = [ config_get('post_edit_hook'), - os.path.join(config_get('data_dir', 'data'), self.page_name), remote_user(), + self.page_name, remote_user(), remote_host(), changelog ] child = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True) output = child.stdout.read() @@ -824,6 +823,7 @@ class Page: try: exec(open("geekigeeki.conf.py").read()) + os.chdir(config_get('data_dir', 'data')) form = cgi.FieldStorage() action = form.getvalue('a', 'get') handler = globals().get('handle_' + action)