Commits

Ronny Pfannschmidt  committed aa7990f

make views operate the same way

  • Participants
  • Parent commits dc42f69

Comments (0)

Files changed (1)

File persona/__init__.py

     return src
 
 def provision(env):
-	return 200, 'provision.html'
+    return 200, 'html', 'provision.html'
 
 def authenticate(env):
-	return 200, 'authenticate.html'
+    return 200, 'html', 'authenticate.html'
 
 def post_data(env, decode=None):
     assert env['REQUEST_METHOD'] == 'POST'
 	return 200, 'text', sign(claims, KEY)
 
 def not_found(env):
-    return 404, 'text', 'not found'
+    return 404, 'text', '%r not found' % env['PATH_INFO']
 
 handlers = {
     'provision': provision,
 
 def application(env, respond):
     call = handler(env)
-    rsp = call(env)
+    status, ct, data = call(env)
 
-    if rsp[1].endswith('.html'):
+    if ct == 'html':
         headers = {'Content-Type': 'text/html; charset=utf-8'}
         persona = 'http://login.persona.org'
         if env.get('HTTP_REFERER'):
             referrer = urlparse.urlparse(env['HTTP_REFERER'])
             persona = referrer.scheme + '://' + referrer.netloc
-        content = render(rsp[1], {'key': STORAGE_KEY, 'persona': persona})
+        content = render(data, {'key': STORAGE_KEY, 'persona': persona})
 
-    elif rsp[1] == 'json':
+    elif ct == 'json':
         headers = {'Content-Type': 'application/json'}
-        content = json.dumps(rsp[2])
+        content = json.dumps(data)
 
-    elif rsp[1] == 'text':
+    elif ct == 'text':
         headers = {'Content-Type': 'text/plain; charset=utf-8'}
-        content = rsp[2]
+        content = data
 
     status = {200: '200 OK', 404: '404 Not Found'}
     respond(status[rsp[0]], headers.items())