Get configuration keys at runtime, not when module is imported (fixes #64)

This commit is contained in:
Guillaume Ayoub
2013-09-12 13:48:49 +02:00
parent f5f31ca978
commit 43785e48a9
2 changed files with 17 additions and 19 deletions

View File

@@ -55,13 +55,6 @@ VERSION = "git"
# tries to access information they don't have rights to
NOT_ALLOWED = (client.FORBIDDEN, {}, None)
# Standard "authenticate" response that is returned when a user tries to access
# non-public information w/o submitting proper authentication credentials
WRONG_CREDENTIALS = (
client.UNAUTHORIZED,
{"WWW-Authenticate": "Basic realm=\"%s\"" % config.get("server", "realm")},
None)
class HTTPServer(wsgiref.simple_server.WSGIServer, object):
"""HTTP server."""
@@ -303,7 +296,11 @@ class Application(object):
else:
# Unknown or unauthorized user
log.LOGGER.info("%s refused" % (user or "Anonymous user"))
status, headers, answer = WRONG_CREDENTIALS
status = client.UNAUTHORIZED
headers = {
"WWW-Authenticate":
"Basic realm=\"%s\"" % config.get("server", "realm")}
answer = None
# Set content length
if answer: