From b9db2bd04b6007004057410623024c880660bd72 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Mon, 17 Aug 2009 19:29:45 +0200 Subject: [PATCH] Use config_get() to access configuration values --- geekigeeki.py | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/geekigeeki.py b/geekigeeki.py index eb51489..73c45ce 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -36,6 +36,9 @@ url_re = re.compile(r"[a-z]{3,8}://[^\s'\"]+\S") ext_re = re.compile(r"\.([^\./]+)$") # CGI stuff --------------------------------------------------------- +def config_get(key, default=None): + return globals().get(key, default) + def script_name(): return os.environ.get('SCRIPT_NAME', '') @@ -129,16 +132,15 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal print(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">') print('') - print("%s: %s" % (site_name, text)) + print("%s: %s" % (config_get('site_name', "Unconfigured Wiki"), text)) print(' ') if not name: print(' ') - for meta in meta_urls: - http_equiv, content = meta + for http_equiv, content in config_get('meta_urls', {}): print(' ' % (http_equiv, relative_url(content))) - for link in link_urls: + for link in config_get('link_urls', {}): rel, href = link print(' ' % (rel, relative_url(href))) @@ -146,9 +148,10 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal print(' ' \ % (privileged_path() + '?a=edit&q=' + name)) - if history_url is not None: + history = config_get('history_url') + if history is not None: print(' ' \ - % relative_url(history_url + '?a=rss')) + % relative_url(history + '?a=rss')) print('') @@ -163,16 +166,16 @@ def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=Fal # Navbar print('