re-read the mapping file for every access

This commit is contained in:
lars 2011-03-28 19:48:56 +00:00
parent 039c5947a5
commit 19fd6d004e

View file

@ -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)