1.1 --- a/WebStack/ModPython.py Mon Aug 16 18:13:45 2004 +0000
1.2 +++ b/WebStack/ModPython.py Thu Aug 26 20:37:21 2004 +0000
1.3 @@ -8,11 +8,13 @@
1.4 from Helpers.Response import ConvertingStream
1.5 from mod_python.util import parse_qs, FieldStorage
1.6 from mod_python import apache
1.7 -try:
1.8 - from mod_python import Cookie
1.9 -except ImportError:
1.10 - # NOTE: Should provide an alternative implementation.
1.11 - Cookie = None
1.12 +
1.13 +# NOTE: Should provide alternative implementations.
1.14 +
1.15 +try: from mod_python import Cookie
1.16 +except ImportError: Cookie = None
1.17 +try: from mod_python import Session
1.18 +except ImportError: Session = None
1.19
1.20 class Transaction(Generic.Transaction):
1.21
1.22 @@ -341,6 +343,40 @@
1.23 # NOTE: Should raise an exception or provide an implementation.
1.24 pass
1.25
1.26 + # Session-related methods.
1.27 +
1.28 + def get_session(self, create=1):
1.29 +
1.30 + """
1.31 + A framework-specific method which returns a session corresponding to
1.32 + an identifier supplied in the transaction.
1.33 +
1.34 + If no session has yet been established according to information
1.35 + provided in the transaction then the optional 'create' parameter
1.36 + determines whether a new session will be established.
1.37 +
1.38 + Where no session has been established and where 'create' is set to 0
1.39 + then None is returned. In all other cases, a session object is created
1.40 + (where appropriate) and returned.
1.41 + """
1.42 +
1.43 + if Session:
1.44 + # NOTE: Not exposing all functionality.
1.45 + return Session.Session(self.trans)
1.46 + else:
1.47 + return None
1.48 +
1.49 + def expire_session(self):
1.50 +
1.51 + """
1.52 + A framework-specific method which expires any session established
1.53 + according to information provided in the transaction.
1.54 + """
1.55 +
1.56 + session = self.get_session(create=0)
1.57 + if session:
1.58 + session.invalidate()
1.59 +
1.60 # Application-specific methods.
1.61
1.62 def set_user(self, username):