paulb@1 | 1 | #!/usr/bin/env python |
paulb@1 | 2 | |
paulb@1 | 3 | """ |
paulb@1 | 4 | mod_python classes. |
paulb@1 | 5 | """ |
paulb@1 | 6 | |
paulb@1 | 7 | import Generic |
paulb@258 | 8 | from Helpers.Request import get_body_field, filter_fields, Cookie |
paulb@167 | 9 | from Helpers.Response import ConvertingStream |
paulb@71 | 10 | from mod_python.util import parse_qs, FieldStorage |
paulb@42 | 11 | from mod_python import apache |
paulb@183 | 12 | |
paulb@245 | 13 | # Provide alternative implementations. |
paulb@245 | 14 | # The alternative session support requires cookie support of some kind. |
paulb@183 | 15 | |
paulb@245 | 16 | try: |
paulb@258 | 17 | from mod_python.Cookie import get_cookies, add_cookie, Cookie as SimpleCookie |
paulb@258 | 18 | have_cookies = 1 |
paulb@245 | 19 | except ImportError: |
paulb@245 | 20 | from Cookie import SimpleCookie |
paulb@258 | 21 | have_cookies = 0 |
paulb@239 | 22 | try: |
paulb@239 | 23 | from mod_python import Session |
paulb@239 | 24 | except ImportError: |
paulb@239 | 25 | from Helpers.Session import SessionStore |
paulb@239 | 26 | import os |
paulb@239 | 27 | Session = None |
paulb@1 | 28 | |
paulb@1 | 29 | class Transaction(Generic.Transaction): |
paulb@1 | 30 | |
paulb@1 | 31 | """ |
paulb@1 | 32 | mod_python transaction interface. |
paulb@1 | 33 | """ |
paulb@1 | 34 | |
paulb@1 | 35 | def __init__(self, trans): |
paulb@1 | 36 | |
paulb@1 | 37 | "Initialise the transaction using the mod_python transaction 'trans'." |
paulb@1 | 38 | |
paulb@1 | 39 | self.trans = trans |
paulb@42 | 40 | self.response_code = apache.OK |
paulb@311 | 41 | self.content_type = None |
paulb@128 | 42 | self.user = None |
paulb@311 | 43 | self.path_info = None |
paulb@1 | 44 | |
paulb@245 | 45 | # Support non-framework cookies. |
paulb@245 | 46 | |
paulb@258 | 47 | if not have_cookies: |
paulb@245 | 48 | |
paulb@245 | 49 | # Define the incoming cookies. |
paulb@245 | 50 | |
paulb@245 | 51 | self.cookies_in = SimpleCookie(self.get_headers().get("cookie")) |
paulb@245 | 52 | |
paulb@133 | 53 | # Cached information. |
paulb@133 | 54 | |
paulb@133 | 55 | self.storage_body = None |
paulb@133 | 56 | |
paulb@239 | 57 | # Special objects retained throughout the transaction. |
paulb@239 | 58 | |
paulb@239 | 59 | self.session_store = None |
paulb@372 | 60 | self.session = None # mod_python native session |
paulb@239 | 61 | |
paulb@239 | 62 | def commit(self): |
paulb@239 | 63 | |
paulb@239 | 64 | """ |
paulb@239 | 65 | A special method, synchronising the transaction with framework-specific |
paulb@239 | 66 | objects. |
paulb@239 | 67 | """ |
paulb@239 | 68 | |
paulb@239 | 69 | # Close the session store. |
paulb@239 | 70 | |
paulb@239 | 71 | if self.session_store is not None: |
paulb@239 | 72 | self.session_store.close() |
paulb@239 | 73 | |
paulb@372 | 74 | # Commit any native session. |
paulb@372 | 75 | |
paulb@372 | 76 | if self.session is not None: |
paulb@372 | 77 | self.session.save() |
paulb@372 | 78 | |
paulb@338 | 79 | # Server-related methods. |
paulb@338 | 80 | |
paulb@338 | 81 | def get_server_name(self): |
paulb@338 | 82 | |
paulb@338 | 83 | "Returns the server name." |
paulb@338 | 84 | |
paulb@395 | 85 | return self.trans.server.server_hostname |
paulb@338 | 86 | |
paulb@338 | 87 | def get_server_port(self): |
paulb@338 | 88 | |
paulb@338 | 89 | "Returns the server port as a string." |
paulb@338 | 90 | |
paulb@338 | 91 | return str(self.trans.connection.local_addr[1]) |
paulb@338 | 92 | |
paulb@1 | 93 | # Request-related methods. |
paulb@1 | 94 | |
paulb@1 | 95 | def get_request_stream(self): |
paulb@1 | 96 | |
paulb@1 | 97 | """ |
paulb@186 | 98 | Returns the request stream for the transaction. |
paulb@1 | 99 | """ |
paulb@1 | 100 | |
paulb@1 | 101 | return self.trans |
paulb@1 | 102 | |
paulb@1 | 103 | def get_request_method(self): |
paulb@1 | 104 | |
paulb@1 | 105 | """ |
paulb@186 | 106 | Returns the request method. |
paulb@1 | 107 | """ |
paulb@1 | 108 | |
paulb@1 | 109 | return self.trans.method |
paulb@1 | 110 | |
paulb@1 | 111 | def get_headers(self): |
paulb@1 | 112 | |
paulb@1 | 113 | """ |
paulb@186 | 114 | Returns all request headers as a dictionary-like object mapping header |
paulb@186 | 115 | names to values. |
paulb@186 | 116 | |
paulb@91 | 117 | NOTE: If duplicate header names are permitted, then this interface will |
paulb@91 | 118 | NOTE: need to change. |
paulb@1 | 119 | """ |
paulb@1 | 120 | |
paulb@1 | 121 | return self.trans.headers_in |
paulb@1 | 122 | |
paulb@65 | 123 | def get_header_values(self, key): |
paulb@65 | 124 | |
paulb@65 | 125 | """ |
paulb@186 | 126 | Returns a list of all request header values associated with the given |
paulb@186 | 127 | 'key'. Note that according to RFC 2616, 'key' is treated as a |
paulb@186 | 128 | case-insensitive string. |
paulb@65 | 129 | """ |
paulb@65 | 130 | |
paulb@65 | 131 | return self.convert_to_list(self.trans.headers_in.get(key)) |
paulb@65 | 132 | |
paulb@1 | 133 | def get_content_type(self): |
paulb@1 | 134 | |
paulb@1 | 135 | """ |
paulb@186 | 136 | Returns the content type specified on the request, along with the |
paulb@186 | 137 | charset employed. |
paulb@1 | 138 | """ |
paulb@1 | 139 | |
paulb@1 | 140 | return self.parse_content_type(self.trans.content_type) |
paulb@1 | 141 | |
paulb@1 | 142 | def get_content_charsets(self): |
paulb@1 | 143 | |
paulb@1 | 144 | """ |
paulb@1 | 145 | Returns the character set preferences. |
paulb@1 | 146 | """ |
paulb@1 | 147 | |
paulb@108 | 148 | return self.parse_content_preferences(self.trans.headers_in.get("Accept-Charset")) |
paulb@1 | 149 | |
paulb@1 | 150 | def get_content_languages(self): |
paulb@1 | 151 | |
paulb@1 | 152 | """ |
paulb@186 | 153 | Returns extracted language information from the transaction. |
paulb@1 | 154 | """ |
paulb@1 | 155 | |
paulb@108 | 156 | return self.parse_content_preferences(self.trans.headers_in.get("Accept-Language")) |
paulb@1 | 157 | |
paulb@5 | 158 | def get_path(self): |
paulb@5 | 159 | |
paulb@5 | 160 | """ |
paulb@186 | 161 | Returns the entire path from the request. |
paulb@5 | 162 | """ |
paulb@5 | 163 | |
paulb@144 | 164 | query_string = self.get_query_string() |
paulb@144 | 165 | if query_string: |
paulb@144 | 166 | return self.trans.uri + "?" + query_string |
paulb@144 | 167 | else: |
paulb@144 | 168 | return self.trans.uri |
paulb@5 | 169 | |
paulb@162 | 170 | def get_path_without_query(self): |
paulb@162 | 171 | |
paulb@162 | 172 | """ |
paulb@186 | 173 | Returns the entire path from the request minus the query string. |
paulb@162 | 174 | """ |
paulb@162 | 175 | |
paulb@162 | 176 | return self.trans.uri |
paulb@162 | 177 | |
paulb@1 | 178 | def get_path_info(self): |
paulb@1 | 179 | |
paulb@1 | 180 | """ |
paulb@186 | 181 | Returns the "path info" (the part of the URL after the resource name |
paulb@186 | 182 | handling the current request) from the request. |
paulb@1 | 183 | """ |
paulb@1 | 184 | |
paulb@316 | 185 | return self.trans.path_info |
paulb@1 | 186 | |
paulb@69 | 187 | def get_query_string(self): |
paulb@69 | 188 | |
paulb@69 | 189 | """ |
paulb@186 | 190 | Returns the query string from the path in the request. |
paulb@69 | 191 | """ |
paulb@69 | 192 | |
paulb@73 | 193 | return self.trans.args or "" |
paulb@69 | 194 | |
paulb@1 | 195 | # Higher level request-related methods. |
paulb@1 | 196 | |
paulb@69 | 197 | def get_fields_from_path(self): |
paulb@69 | 198 | |
paulb@69 | 199 | """ |
paulb@249 | 200 | Extracts fields (or request parameters) from the path specified in the |
paulb@249 | 201 | transaction. The underlying framework may refuse to supply fields from |
paulb@249 | 202 | the path if handling a POST transaction. |
paulb@69 | 203 | |
paulb@71 | 204 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@71 | 205 | single value is associated with any given field name). |
paulb@69 | 206 | """ |
paulb@69 | 207 | |
paulb@249 | 208 | # NOTE: Support at best ISO-8859-1 values. |
paulb@249 | 209 | |
paulb@249 | 210 | fields = {} |
paulb@249 | 211 | for name, values in parse_qs(self.get_query_string(), 1).items(): # keep_blank_values=1 |
paulb@249 | 212 | fields[name] = [] |
paulb@249 | 213 | for value in values: |
paulb@249 | 214 | fields[name].append(unicode(value, "iso-8859-1")) |
paulb@249 | 215 | return fields |
paulb@69 | 216 | |
paulb@167 | 217 | def get_fields_from_body(self, encoding=None): |
paulb@69 | 218 | |
paulb@69 | 219 | """ |
paulb@249 | 220 | Extracts fields (or request parameters) from the message body in the |
paulb@249 | 221 | transaction. The optional 'encoding' parameter specifies the character |
paulb@249 | 222 | encoding of the message body for cases where no such information is |
paulb@249 | 223 | available, but where the default encoding is to be overridden. |
paulb@69 | 224 | |
paulb@73 | 225 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@193 | 226 | single value is associated with any given field name). Each value is |
paulb@193 | 227 | either a Unicode object (representing a simple form field, for example) |
paulb@198 | 228 | or a plain string (representing a file upload form field, for example). |
paulb@69 | 229 | |
paulb@69 | 230 | The mod_python.util.FieldStorage class may augment the fields from the |
paulb@69 | 231 | body with fields found in the path. |
paulb@69 | 232 | """ |
paulb@69 | 233 | |
paulb@249 | 234 | all_fields = self._get_fields(encoding) |
paulb@249 | 235 | fields_from_path = self.get_fields_from_path() |
paulb@249 | 236 | return filter_fields(all_fields, fields_from_path) |
paulb@249 | 237 | |
paulb@249 | 238 | def _get_fields(self, encoding=None): |
paulb@224 | 239 | encoding = encoding or self.get_content_type().charset or self.default_charset |
paulb@167 | 240 | |
paulb@133 | 241 | if self.storage_body is None: |
paulb@133 | 242 | self.storage_body = FieldStorage(self.trans, keep_blank_values=1) |
paulb@69 | 243 | |
paulb@73 | 244 | # Traverse the storage, finding each field value. |
paulb@1 | 245 | |
paulb@73 | 246 | fields = {} |
paulb@133 | 247 | for field in self.storage_body.list: |
paulb@73 | 248 | if not fields.has_key(field.name): |
paulb@73 | 249 | fields[field.name] = [] |
paulb@198 | 250 | fields[field.name].append(get_body_field(field.value, encoding)) |
paulb@73 | 251 | return fields |
paulb@1 | 252 | |
paulb@249 | 253 | def get_fields(self, encoding=None): |
paulb@249 | 254 | |
paulb@249 | 255 | """ |
paulb@249 | 256 | Extracts fields (or request parameters) from both the path specified in |
paulb@249 | 257 | the transaction as well as the message body. The optional 'encoding' |
paulb@249 | 258 | parameter specifies the character encoding of the message body for cases |
paulb@249 | 259 | where no such information is available, but where the default encoding |
paulb@249 | 260 | is to be overridden. |
paulb@249 | 261 | |
paulb@249 | 262 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@249 | 263 | single value is associated with any given field name). Each value is |
paulb@249 | 264 | either a Unicode object (representing a simple form field, for example) |
paulb@249 | 265 | or a plain string (representing a file upload form field, for example). |
paulb@249 | 266 | |
paulb@249 | 267 | Where a given field name is used in both the path and message body to |
paulb@249 | 268 | specify values, the values from both sources will be combined into a |
paulb@249 | 269 | single list associated with that field name. |
paulb@249 | 270 | """ |
paulb@249 | 271 | |
paulb@249 | 272 | return self._get_fields(encoding) |
paulb@249 | 273 | |
paulb@45 | 274 | def get_user(self): |
paulb@1 | 275 | |
paulb@1 | 276 | """ |
paulb@186 | 277 | Extracts user information from the transaction. |
paulb@108 | 278 | |
paulb@108 | 279 | Returns a username as a string or None if no user is defined. |
paulb@1 | 280 | """ |
paulb@1 | 281 | |
paulb@128 | 282 | if self.user is not None: |
paulb@128 | 283 | return self.user |
paulb@128 | 284 | else: |
paulb@128 | 285 | return self.trans.user |
paulb@1 | 286 | |
paulb@98 | 287 | def get_cookies(self): |
paulb@98 | 288 | |
paulb@98 | 289 | """ |
paulb@186 | 290 | Obtains cookie information from the request. |
paulb@98 | 291 | |
paulb@98 | 292 | Returns a dictionary mapping cookie names to cookie objects. |
paulb@98 | 293 | |
paulb@98 | 294 | NOTE: No additional information is passed to the underlying API despite |
paulb@98 | 295 | NOTE: support for enhanced cookies in mod_python. |
paulb@98 | 296 | """ |
paulb@98 | 297 | |
paulb@258 | 298 | if have_cookies: |
paulb@258 | 299 | found_cookies = get_cookies(self.trans) |
paulb@137 | 300 | else: |
paulb@258 | 301 | found_cookies = self.cookies_in |
paulb@258 | 302 | return self.process_cookies(found_cookies) |
paulb@98 | 303 | |
paulb@104 | 304 | def get_cookie(self, cookie_name): |
paulb@104 | 305 | |
paulb@104 | 306 | """ |
paulb@186 | 307 | Obtains cookie information from the request. |
paulb@104 | 308 | |
paulb@104 | 309 | Returns a cookie object for the given 'cookie_name' or None if no such |
paulb@104 | 310 | cookie exists. |
paulb@104 | 311 | """ |
paulb@104 | 312 | |
paulb@267 | 313 | return self.get_cookies().get(self.encode_cookie_value(cookie_name)) |
paulb@104 | 314 | |
paulb@1 | 315 | # Response-related methods. |
paulb@1 | 316 | |
paulb@1 | 317 | def get_response_stream(self): |
paulb@1 | 318 | |
paulb@1 | 319 | """ |
paulb@186 | 320 | Returns the response stream for the transaction. |
paulb@1 | 321 | """ |
paulb@1 | 322 | |
paulb@224 | 323 | # Unicode can upset this operation. Using either the specified charset |
paulb@224 | 324 | # or a default encoding. |
paulb@167 | 325 | |
paulb@252 | 326 | encoding = self.get_response_stream_encoding() |
paulb@252 | 327 | return ConvertingStream(self.trans, encoding) |
paulb@252 | 328 | |
paulb@252 | 329 | def get_response_stream_encoding(self): |
paulb@252 | 330 | |
paulb@252 | 331 | """ |
paulb@252 | 332 | Returns the response stream encoding. |
paulb@252 | 333 | """ |
paulb@252 | 334 | |
paulb@167 | 335 | if self.content_type: |
paulb@224 | 336 | encoding = self.content_type.charset |
paulb@252 | 337 | else: |
paulb@252 | 338 | encoding = None |
paulb@252 | 339 | return encoding or self.default_charset |
paulb@1 | 340 | |
paulb@42 | 341 | def get_response_code(self): |
paulb@42 | 342 | |
paulb@42 | 343 | """ |
paulb@42 | 344 | Get the response code associated with the transaction. If no response |
paulb@42 | 345 | code is defined, None is returned. |
paulb@42 | 346 | """ |
paulb@42 | 347 | |
paulb@42 | 348 | return self.response_code |
paulb@42 | 349 | |
paulb@42 | 350 | def set_response_code(self, response_code): |
paulb@42 | 351 | |
paulb@42 | 352 | """ |
paulb@42 | 353 | Set the 'response_code' using a numeric constant defined in the HTTP |
paulb@42 | 354 | specification. |
paulb@42 | 355 | """ |
paulb@42 | 356 | |
paulb@42 | 357 | self.response_code = response_code |
paulb@42 | 358 | |
paulb@67 | 359 | def set_header_value(self, header, value): |
paulb@49 | 360 | |
paulb@49 | 361 | """ |
paulb@49 | 362 | Set the HTTP 'header' with the given 'value'. |
paulb@49 | 363 | """ |
paulb@49 | 364 | |
paulb@49 | 365 | self.trans.headers_out[self.format_header_value(header)] = self.format_header_value(value) |
paulb@49 | 366 | |
paulb@1 | 367 | def set_content_type(self, content_type): |
paulb@1 | 368 | |
paulb@1 | 369 | """ |
paulb@186 | 370 | Sets the 'content_type' for the response. |
paulb@1 | 371 | """ |
paulb@1 | 372 | |
paulb@167 | 373 | # Remember the content type for encoding purposes later. |
paulb@167 | 374 | |
paulb@167 | 375 | self.content_type = content_type |
paulb@224 | 376 | self.trans.content_type = str(content_type) |
paulb@1 | 377 | |
paulb@186 | 378 | # Higher level response-related methods. |
paulb@186 | 379 | |
paulb@98 | 380 | def set_cookie(self, cookie): |
paulb@98 | 381 | |
paulb@98 | 382 | """ |
paulb@186 | 383 | Stores the given 'cookie' object in the response. |
paulb@98 | 384 | """ |
paulb@98 | 385 | |
paulb@258 | 386 | # NOTE: If multiple cookies of the same name could be specified, this |
paulb@258 | 387 | # NOTE: could need changing. |
paulb@245 | 388 | |
paulb@258 | 389 | self.set_cookie_value(cookie.name, cookie.value) |
paulb@98 | 390 | |
paulb@98 | 391 | def set_cookie_value(self, name, value, path=None, expires=None): |
paulb@98 | 392 | |
paulb@98 | 393 | """ |
paulb@186 | 394 | Stores a cookie with the given 'name' and 'value' in the response. |
paulb@98 | 395 | |
paulb@98 | 396 | The optional 'path' is a string which specifies the scope of the cookie, |
paulb@98 | 397 | and the optional 'expires' parameter is a value compatible with the |
paulb@98 | 398 | time.time function, and indicates the expiry date/time of the cookie. |
paulb@98 | 399 | """ |
paulb@98 | 400 | |
paulb@258 | 401 | name = self.encode_cookie_value(name) |
paulb@104 | 402 | |
paulb@258 | 403 | if have_cookies: |
paulb@258 | 404 | cookie = SimpleCookie(name, self.encode_cookie_value(value)) |
paulb@98 | 405 | if expires is not None: |
paulb@98 | 406 | cookie.expires = expires |
paulb@98 | 407 | if path is not None: |
paulb@98 | 408 | cookie.path = path |
paulb@258 | 409 | add_cookie(self.trans, cookie) |
paulb@98 | 410 | else: |
paulb@245 | 411 | cookie_out = SimpleCookie() |
paulb@258 | 412 | cookie_out[name] = self.encode_cookie_value(value) |
paulb@245 | 413 | if path is not None: |
paulb@245 | 414 | cookie_out[name]["path"] = path |
paulb@245 | 415 | if expires is not None: |
paulb@245 | 416 | cookie_out[name]["expires"] = expires |
paulb@245 | 417 | self._write_cookie(cookie_out) |
paulb@98 | 418 | |
paulb@98 | 419 | def delete_cookie(self, cookie_name): |
paulb@98 | 420 | |
paulb@98 | 421 | """ |
paulb@186 | 422 | Adds to the response a request that the cookie with the given |
paulb@186 | 423 | 'cookie_name' be deleted/discarded by the client. |
paulb@98 | 424 | """ |
paulb@98 | 425 | |
paulb@98 | 426 | # Create a special cookie, given that we do not know whether the browser |
paulb@98 | 427 | # has been sent the cookie or not. |
paulb@98 | 428 | # NOTE: Magic discovered in Webware. |
paulb@98 | 429 | |
paulb@258 | 430 | name = self.encode_cookie_value(cookie_name) |
paulb@258 | 431 | |
paulb@258 | 432 | if have_cookies: |
paulb@258 | 433 | cookie = SimpleCookie(name, "") |
paulb@98 | 434 | cookie.path = "/" |
paulb@98 | 435 | cookie.expires = 0 |
paulb@98 | 436 | cookie.max_age = 0 |
paulb@258 | 437 | add_cookie(self.trans, cookie) |
paulb@98 | 438 | else: |
paulb@245 | 439 | cookie_out = SimpleCookie() |
paulb@258 | 440 | cookie_out[name] = "" |
paulb@258 | 441 | cookie_out[name]["path"] = "/" |
paulb@258 | 442 | cookie_out[name]["expires"] = 0 |
paulb@258 | 443 | cookie_out[name]["max-age"] = 0 |
paulb@245 | 444 | self._write_cookie(cookie_out) |
paulb@245 | 445 | |
paulb@245 | 446 | def _write_cookie(self, cookie): |
paulb@245 | 447 | |
paulb@245 | 448 | "An internal method adding the given 'cookie' to the headers." |
paulb@245 | 449 | |
paulb@245 | 450 | # NOTE: May not be using the appropriate method. |
paulb@245 | 451 | |
paulb@245 | 452 | for morsel in cookie.values(): |
paulb@245 | 453 | self.set_header_value("Set-Cookie", morsel.OutputString()) |
paulb@98 | 454 | |
paulb@183 | 455 | # Session-related methods. |
paulb@183 | 456 | |
paulb@183 | 457 | def get_session(self, create=1): |
paulb@183 | 458 | |
paulb@183 | 459 | """ |
paulb@186 | 460 | Gets a session corresponding to an identifier supplied in the |
paulb@186 | 461 | transaction. |
paulb@183 | 462 | |
paulb@183 | 463 | If no session has yet been established according to information |
paulb@183 | 464 | provided in the transaction then the optional 'create' parameter |
paulb@183 | 465 | determines whether a new session will be established. |
paulb@183 | 466 | |
paulb@183 | 467 | Where no session has been established and where 'create' is set to 0 |
paulb@183 | 468 | then None is returned. In all other cases, a session object is created |
paulb@183 | 469 | (where appropriate) and returned. |
paulb@183 | 470 | """ |
paulb@183 | 471 | |
paulb@183 | 472 | if Session: |
paulb@183 | 473 | # NOTE: Not exposing all functionality. |
paulb@372 | 474 | self.session = Session.Session(self.trans) |
paulb@372 | 475 | self.session.load() |
paulb@372 | 476 | return self.session |
paulb@183 | 477 | else: |
paulb@239 | 478 | # NOTE: Requires configuration. |
paulb@239 | 479 | |
paulb@239 | 480 | if self.session_store is None: |
paulb@239 | 481 | self.session_store = SessionStore(self, os.path.join(apache.server_root(), "WebStack-sessions")) |
paulb@239 | 482 | return self.session_store.get_session(create) |
paulb@183 | 483 | |
paulb@183 | 484 | def expire_session(self): |
paulb@183 | 485 | |
paulb@183 | 486 | """ |
paulb@186 | 487 | Expires any session established according to information provided in the |
paulb@186 | 488 | transaction. |
paulb@183 | 489 | """ |
paulb@183 | 490 | |
paulb@239 | 491 | if Session: |
paulb@372 | 492 | if self.session is None: |
paulb@372 | 493 | self.session = self.get_session(create=0) |
paulb@372 | 494 | if self.session: |
paulb@372 | 495 | self.session.invalidate() |
paulb@372 | 496 | self.session = None |
paulb@239 | 497 | else: |
paulb@239 | 498 | # NOTE: Requires configuration. |
paulb@239 | 499 | |
paulb@239 | 500 | if self.session_store is None: |
paulb@239 | 501 | self.session_store = SessionStore(self, os.path.join(apache.server_root(), "WebStack-sessions")) |
paulb@239 | 502 | self.session_store.expire_session() |
paulb@183 | 503 | |
paulb@1 | 504 | # vim: tabstop=4 expandtab shiftwidth=4 |