diff options
Diffstat (limited to '')
-rwxr-xr-x | sca-cpp/trunk/modules/wsgi/composite.py | 19 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/wsgi/jsonutil.py | 6 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/wsgi/scdl.py | 10 |
3 files changed, 31 insertions, 4 deletions
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) diff --git a/sca-cpp/trunk/modules/wsgi/jsonutil.py b/sca-cpp/trunk/modules/wsgi/jsonutil.py index ae7839df57..f69559de54 100644 --- a/sca-cpp/trunk/modules/wsgi/jsonutil.py +++ b/sca-cpp/trunk/modules/wsgi/jsonutil.py @@ -132,9 +132,11 @@ def jsonResultValue(s): # Return a portable function name from a JSON-RPC function name def funcName(f): - if len(f) > 7 and f.find("system.") == 0: + if f.startswith("."): + return f[1:] + if f.startswith("system."): return f[7:] - if len(f) > 8 and f.find("Service.") == 0: + if f.startswith("Service."): return f[8:] return f diff --git a/sca-cpp/trunk/modules/wsgi/scdl.py b/sca-cpp/trunk/modules/wsgi/scdl.py index a50bba3b7a..309f7f91f8 100644 --- a/sca-cpp/trunk/modules/wsgi/scdl.py +++ b/sca-cpp/trunk/modules/wsgi/scdl.py @@ -19,6 +19,7 @@ from xml.etree.cElementTree import iterparse from sys import stderr +from os import environ from util import * from httputil import * @@ -186,9 +187,11 @@ def evalReference(r, comps): return nameToComponent(t, comps) # Evaluate a property, return a lambda function returning the property -# value. The user and email properties are configured with the values -# from the HTTP request, if any +# value. The host, user and email properties are configured with the +# values from the HTTP request, if any def evalProperty(p): + if car(p) == "host": + return lambda: hostProperty(cadr(p), environ) if car(p) == "user": return lambda: userProperty(cadr(p)) if car(p) == "email": @@ -206,6 +209,9 @@ def userProperty(v): user = currentUser() return user.user_id() if user else v +def hostProperty(v, e): + return e.get("HTTP_HOST", e.get("SERVER_NAME", v)).split(":")[0] + def emailProperty(v): user = currentUser() return user.email() if user else v |