1.1 --- a/WebStack/Twisted.py Thu May 27 22:18:00 2004 +0000
1.2 +++ b/WebStack/Twisted.py Sat May 29 17:25:44 2004 +0000
1.3 @@ -20,6 +20,7 @@
1.4 "Initialise the transaction using the Twisted transaction 'trans'."
1.5
1.6 self.trans = trans
1.7 + self.user = None
1.8
1.9 # Request-related methods.
1.10
1.11 @@ -160,7 +161,10 @@
1.12 Returns a username as a string or None if no user is defined.
1.13 """
1.14
1.15 - # NOTE: Twisted makes headers lower case, for some reason.
1.16 + # Twisted makes headers lower case.
1.17 +
1.18 + if self.user is not None:
1.19 + return self.user
1.20
1.21 auth_header = self.get_headers().get("authorization")
1.22 if auth_header:
1.23 @@ -287,4 +291,16 @@
1.24
1.25 self.trans.addCookie(cookie_name, "", expires=0, path="/", max_age=0)
1.26
1.27 + # Application-specific methods.
1.28 +
1.29 + def set_user(self, username):
1.30 +
1.31 + """
1.32 + An application-specific method which sets the user information with
1.33 + 'username' in the transaction. This affects subsequent calls to
1.34 + 'get_user'.
1.35 + """
1.36 +
1.37 + self.user = username
1.38 +
1.39 # vim: tabstop=4 expandtab shiftwidth=4