From 26c5927dcc5ad65edab01f2f53736cec8a637b95 Mon Sep 17 00:00:00 2001 From: Ramana Juvvadi Date: Fri, 6 May 2011 23:50:45 -0500 Subject: minor tweak --- .gitignore | 4 ++++ keystone/auth_server.py | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 0d20b648..7ca76827 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ *.pyc +.project/ +.cache/ +.pydevproject/ +keystone.db diff --git a/keystone/auth_server.py b/keystone/auth_server.py index dbfe9dbd..4b14d48c 100755 --- a/keystone/auth_server.py +++ b/keystone/auth_server.py @@ -64,10 +64,10 @@ import keystone.logic.types.auth as auth service = serv.IDMService() -def is_xml_response(): - if not "Accept" in request.header: +def is_xml_response(req): + if not "Accept" in req.headers: return False - return request.header["Accept"] == "application/xml" + return req.content_type == "application/xml" def get_normalized_request_content(model, req): @@ -82,17 +82,17 @@ def get_normalized_request_content(model, req): return ret -def send_result(code, result): +def send_result(code, req, result): content = None - response.content_type = None + Response.content_type = None if result: - if is_xml_response(): + if is_xml_response(req): content = result.to_xml() - response.content_type = "application/xml" + Response.content_type = "application/xml" else: content = result.to_json() - response.content_type = "application/json" - response.status = code + Response.content_type = "application/json" + Response.status = code if code > 399: #return bottle.abort(code, content) return; @@ -106,7 +106,7 @@ class Controller(wsgi.Controller): def authenticate(self, req): creds = get_normalized_request_content(auth.PasswordCredentials, req) - return send_result(200, service.authenticate(creds)) + return send_result(200, req, service.authenticate(creds)) class Auth_API(wsgi.Router): -- cgit