From c59c7ef6db1f5c6458109f0627a8853c7f162f80 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sat, 17 Jul 2010 22:44:52 +0000 Subject: Support the host property and a /logout URL on WSGI servers. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@965145 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/wsgi/composite.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sca-cpp/trunk/modules/wsgi/composite.py') diff --git a/sca-cpp/trunk/modules/wsgi/composite.py b/sca-cpp/trunk/modules/wsgi/composite.py index 4be44c3101..453718e556 100755 --- a/sca-cpp/trunk/modules/wsgi/composite.py +++ b/sca-cpp/trunk/modules/wsgi/composite.py @@ -86,6 +86,9 @@ def result(e, r, st, h = (), b = None): r("200 OK", list(h + (("Etag", md), ("Expires", "Tue, 01 Jan 1980 00:00:00 GMT")))) return b + if st == 301: + r("301 Moved Permanently", list(h)) + return failure(e, r, 500) # Return an HTTP failure result @@ -115,6 +118,14 @@ def postArgs(a): l = car(a); return cons(l, postArgs(cdr(a))) +# Return the URL of the logout page +def logout(ruri): + try: + from google.appengine.api import users + return users.create_logout_url(ruri) + except: + return None + # WSGI application function def application(e, r): m = requestMethod(e) @@ -132,6 +143,14 @@ def application(e, r): return fileresult(e, r, "application/x-javascript", fpath) if fpath.endswith(".png"): return fileresult(e, r, "image/png", fpath) + if fpath == "/": + return result(e, r, 301, (("Location", "/index.html"),)) + + # Logout + if fpath == "/logout": + redir = logout("/") + if redir: + return result(e, r, 301, (("Location", redir),)) # Find the requested component path = tokens(fpath) -- cgit v1.2.3