1.1 --- a/WebStack/BaseHTTPRequestHandler.py Thu May 27 22:18:00 2004 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Sat May 29 17:25:44 2004 +0000
1.3 @@ -33,6 +33,7 @@
1.4 self.content = StringIO()
1.5 self.headers_out = {}
1.6 self.cookies_out = Cookie.SimpleCookie()
1.7 + self.user = None
1.8
1.9 # Define the incoming cookies.
1.10
1.11 @@ -217,6 +218,9 @@
1.12 Returns a username as a string or None if no user is defined.
1.13 """
1.14
1.15 + if self.user is not None:
1.16 + return self.user
1.17 +
1.18 auth_header = self.get_headers().get("authorization")
1.19 if auth_header:
1.20 return UserInfo(auth_header).username
1.21 @@ -346,4 +350,16 @@
1.22 self.cookies_out[cookie_name]["expires"] = 0
1.23 self.cookies_out[cookie_name]["max-age"] = 0
1.24
1.25 + # Application-specific methods.
1.26 +
1.27 + def set_user(self, username):
1.28 +
1.29 + """
1.30 + An application-specific method which sets the user information with
1.31 + 'username' in the transaction. This affects subsequent calls to
1.32 + 'get_user'.
1.33 + """
1.34 +
1.35 + self.user = username
1.36 +
1.37 # vim: tabstop=4 expandtab shiftwidth=4