From 5e06806d401dd034e6949fa2f853a071ef717720 Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 28 Mar 2011 19:48:56 +0000 Subject: [PATCH] re-read the mapping file for every access --- htman.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htman.py b/htman.py index 634b2b3..ca43d92 100644 --- a/htman.py +++ b/htman.py @@ -58,14 +58,14 @@ def show_files(): # The template expects a list of tuples: (mapping name, admin-url). # We assume, that the admin-url is just below the main admin URL. Thus # there is no need for generating a specific URL. - all_zones = mapping.keys() + all_zones = get_mapping().keys() all_zones.sort() values["mapping"] = [(zone_name, "%s%s/%s" % (web_defaults["base_url"], "admin/manage", zone_name)) for zone_name in all_zones] return render("list_mappings.html", **values) @bobo.query('/manage') def show_htpasswd(htname=None): - if (htname is None) or (not htname in mapping) or (not re.match(REGEX["mapping"], htname)): + if (htname is None) or (not htname in get_mapping()) or (not re.match(REGEX["mapping"], htname)): return bobo.redirect(web_defaults["base_url"]) else: # do a redirect: this allows the webserver to check the permissions for this URL @@ -79,7 +79,7 @@ def manage_htpasswd(htname=None, action=None, username=None, password=None): values = web_defaults.copy() values["error"] = None values["success"] = None - if (htname is None) or (not htname in mapping) or (not re.match(REGEX["mapping"], htname)): + if (htname is None) or (not htname in get_mapping()) or (not re.match(REGEX["mapping"], htname)): return bobo.redirect(web_defaults["base_url"]) values["htname"] = htname htpasswd_file = get_htpasswd_filename(htname) @@ -145,7 +145,7 @@ def get_config(): print >>sys.stderr, "Failed to load config file from %s" % str(CONFIG_FILE_LOCATIONS) sys.exit(1) -def get_mapping(config): +def get_mapping(): try: mapping_file = config.get("Locations", "mapping") except ConfigParser.NoOptionError: @@ -210,7 +210,7 @@ def render(filename, input_data=None, **values): # *** Initialization *** config = get_config() # defaults to the standard TEMPLATES_DIR -mapping = get_mapping(config) +mapping = get_mapping() templates_dir = get_templates_dir(config) web_defaults = dict(config.items("Web")) loader = genshi.template.TemplateLoader([templates_dir], auto_reload=False)