paulb@1 | 1 | #!/usr/bin/env python |
paulb@1 | 2 | |
paulb@1 | 3 | """ |
paulb@1 | 4 | Generic Web framework interfaces. |
paulb@3 | 5 | The WebStack architecture consists of the following layers: |
paulb@3 | 6 | |
paulb@3 | 7 | * Framework - The underlying Web framework implementation. |
paulb@3 | 8 | * Adapter - Code operating under the particular framework which creates |
paulb@3 | 9 | WebStack abstractions and issues them to the application. |
paulb@3 | 10 | * Resources - Units of functionality operating within the hosted Web |
paulb@3 | 11 | application. |
paulb@3 | 12 | |
paulb@3 | 13 | Resources can act as both content producers within an application and as request |
paulb@3 | 14 | dispatchers to other resources; in the latter role, they may be referred to as |
paulb@3 | 15 | directors. |
paulb@1 | 16 | """ |
paulb@1 | 17 | |
paulb@238 | 18 | class HeaderValue: |
paulb@238 | 19 | |
paulb@238 | 20 | "A container for header information." |
paulb@238 | 21 | |
paulb@238 | 22 | def __init__(self, principal_value, **attributes): |
paulb@238 | 23 | |
paulb@238 | 24 | """ |
paulb@238 | 25 | Initialise the container with the given 'principal_value' and optional |
paulb@238 | 26 | keyword attributes representing the key=value pairs which accompany the |
paulb@238 | 27 | 'principal_value'. |
paulb@238 | 28 | """ |
paulb@238 | 29 | |
paulb@238 | 30 | self.principal_value = principal_value |
paulb@238 | 31 | self.attributes = attributes |
paulb@238 | 32 | |
paulb@238 | 33 | def __getattr__(self, name): |
paulb@238 | 34 | if self.attributes.has_key(name): |
paulb@238 | 35 | return self.attributes[name] |
paulb@238 | 36 | else: |
paulb@238 | 37 | raise AttributeError, name |
paulb@238 | 38 | |
paulb@238 | 39 | def __str__(self): |
paulb@238 | 40 | |
paulb@238 | 41 | """ |
paulb@238 | 42 | Format the header value object, producing a string suitable for the |
paulb@238 | 43 | response header field. |
paulb@238 | 44 | """ |
paulb@238 | 45 | |
paulb@238 | 46 | l = [] |
paulb@238 | 47 | if self.principal_value: |
paulb@238 | 48 | l.append(self.principal_value) |
paulb@238 | 49 | for name, value in self.attributes.items(): |
paulb@238 | 50 | l.append("; ") |
paulb@238 | 51 | l.append("%s=%s" % (name, value)) |
paulb@238 | 52 | |
paulb@238 | 53 | # Make sure that only ASCII is used. |
paulb@238 | 54 | |
paulb@238 | 55 | return "".join(l).encode("US-ASCII") |
paulb@238 | 56 | |
paulb@238 | 57 | class ContentType(HeaderValue): |
paulb@1 | 58 | |
paulb@1 | 59 | "A container for content type information." |
paulb@1 | 60 | |
paulb@224 | 61 | def __init__(self, media_type, charset=None, **attributes): |
paulb@224 | 62 | |
paulb@224 | 63 | """ |
paulb@224 | 64 | Initialise the container with the given 'media_type', an optional |
paulb@224 | 65 | 'charset', and optional keyword attributes representing the key=value |
paulb@224 | 66 | pairs which qualify content types. |
paulb@224 | 67 | """ |
paulb@224 | 68 | |
paulb@238 | 69 | if charset is not None: |
paulb@238 | 70 | attributes["charset"] = charset |
paulb@238 | 71 | HeaderValue.__init__(self, media_type, **attributes) |
paulb@219 | 72 | |
paulb@238 | 73 | def __getattr__(self, name): |
paulb@238 | 74 | if name == "media_type": |
paulb@238 | 75 | return self.principal_value |
paulb@238 | 76 | elif name == "charset": |
paulb@238 | 77 | return self.attributes.get("charset") |
paulb@238 | 78 | elif self.attributes.has_key(name): |
paulb@238 | 79 | return self.attributes[name] |
paulb@238 | 80 | else: |
paulb@238 | 81 | raise AttributeError, name |
paulb@1 | 82 | |
paulb@1 | 83 | class Transaction: |
paulb@1 | 84 | |
paulb@1 | 85 | """ |
paulb@1 | 86 | A generic transaction interface containing framework-specific methods to be |
paulb@1 | 87 | overridden. |
paulb@1 | 88 | """ |
paulb@1 | 89 | |
paulb@224 | 90 | # The default charset ties output together with body field interpretation. |
paulb@224 | 91 | |
paulb@224 | 92 | default_charset = "iso-8859-1" |
paulb@224 | 93 | |
paulb@28 | 94 | def commit(self): |
paulb@28 | 95 | |
paulb@28 | 96 | """ |
paulb@28 | 97 | A special method, synchronising the transaction with framework-specific |
paulb@28 | 98 | objects. |
paulb@28 | 99 | """ |
paulb@28 | 100 | |
paulb@28 | 101 | pass |
paulb@28 | 102 | |
paulb@1 | 103 | # Utility methods. |
paulb@1 | 104 | |
paulb@238 | 105 | def parse_header_value(self, header_class, header_value_str): |
paulb@1 | 106 | |
paulb@1 | 107 | """ |
paulb@238 | 108 | Create an object of the given 'header_class' by determining the details |
paulb@238 | 109 | of the given 'header_value_str' - a string containing the value of a |
paulb@238 | 110 | particular header. |
paulb@1 | 111 | """ |
paulb@1 | 112 | |
paulb@238 | 113 | if header_value_str is None: |
paulb@238 | 114 | return header_class(None) |
paulb@1 | 115 | |
paulb@238 | 116 | l = header_value_str.split(";") |
paulb@224 | 117 | attributes = {} |
paulb@193 | 118 | |
paulb@238 | 119 | # Find the attributes. |
paulb@193 | 120 | |
paulb@238 | 121 | principal_value, attributes_str = l[0].strip(), l[1:] |
paulb@5 | 122 | |
paulb@224 | 123 | for attribute_str in attributes_str: |
paulb@224 | 124 | t = attribute_str.split("=") |
paulb@224 | 125 | if len(t) > 1: |
paulb@224 | 126 | name, value = t[0].strip(), t[1].strip() |
paulb@238 | 127 | attributes[name] = value |
paulb@5 | 128 | |
paulb@238 | 129 | return header_class(principal_value, **attributes) |
paulb@238 | 130 | |
paulb@238 | 131 | def parse_content_type(self, content_type_field): |
paulb@238 | 132 | return self.parse_header_value(ContentType, content_type_field) |
paulb@5 | 133 | |
paulb@49 | 134 | def format_header_value(self, value): |
paulb@49 | 135 | |
paulb@49 | 136 | """ |
paulb@49 | 137 | Format the given header 'value'. Typically, this just ensures the usage |
paulb@49 | 138 | of US-ASCII. |
paulb@49 | 139 | """ |
paulb@49 | 140 | |
paulb@49 | 141 | return value.encode("US-ASCII") |
paulb@49 | 142 | |
paulb@1 | 143 | def parse_content_preferences(self, accept_preference): |
paulb@1 | 144 | |
paulb@1 | 145 | """ |
paulb@1 | 146 | Returns the preferences as requested by the user agent. The preferences are |
paulb@1 | 147 | returned as a list of codes in the same order as they appeared in the |
paulb@1 | 148 | appropriate environment variable. In other words, the explicit weighting |
paulb@1 | 149 | criteria are ignored. |
paulb@1 | 150 | |
paulb@1 | 151 | As the 'accept_preference' parameter, values for language and charset |
paulb@1 | 152 | preferences are appropriate. |
paulb@1 | 153 | """ |
paulb@1 | 154 | |
paulb@108 | 155 | if accept_preference is None: |
paulb@108 | 156 | return [] |
paulb@108 | 157 | |
paulb@1 | 158 | accept_defs = accept_preference.split(",") |
paulb@1 | 159 | accept_prefs = [] |
paulb@1 | 160 | for accept_def in accept_defs: |
paulb@1 | 161 | t = accept_def.split(";") |
paulb@1 | 162 | if len(t) >= 1: |
paulb@1 | 163 | accept_prefs.append(t[0].strip()) |
paulb@1 | 164 | return accept_prefs |
paulb@1 | 165 | |
paulb@65 | 166 | def convert_to_list(self, value): |
paulb@65 | 167 | |
paulb@65 | 168 | """ |
paulb@65 | 169 | Returns a single element list containing 'value' if it is not itself a list, a |
paulb@65 | 170 | tuple, or None. If 'value' is a list then it is itself returned; if 'value' is a |
paulb@65 | 171 | tuple then a new list containing the same elements is returned; if 'value' is None |
paulb@65 | 172 | then an empty list is returned. |
paulb@65 | 173 | """ |
paulb@65 | 174 | |
paulb@65 | 175 | if type(value) == type([]): |
paulb@65 | 176 | return value |
paulb@65 | 177 | elif type(value) == type(()): |
paulb@65 | 178 | return list(value) |
paulb@65 | 179 | elif value is None: |
paulb@65 | 180 | return [] |
paulb@65 | 181 | else: |
paulb@65 | 182 | return [value] |
paulb@65 | 183 | |
paulb@1 | 184 | # Request-related methods. |
paulb@1 | 185 | |
paulb@1 | 186 | def get_request_stream(self): |
paulb@1 | 187 | |
paulb@1 | 188 | """ |
paulb@186 | 189 | Returns the request stream for the transaction. |
paulb@1 | 190 | """ |
paulb@1 | 191 | |
paulb@1 | 192 | raise NotImplementedError, "get_request_stream" |
paulb@1 | 193 | |
paulb@1 | 194 | def get_request_method(self): |
paulb@1 | 195 | |
paulb@1 | 196 | """ |
paulb@186 | 197 | Returns the request method. |
paulb@1 | 198 | """ |
paulb@1 | 199 | |
paulb@1 | 200 | raise NotImplementedError, "get_request_method" |
paulb@1 | 201 | |
paulb@1 | 202 | def get_headers(self): |
paulb@1 | 203 | |
paulb@1 | 204 | """ |
paulb@186 | 205 | Returns all request headers as a dictionary-like object mapping header |
paulb@186 | 206 | names to values. |
paulb@1 | 207 | """ |
paulb@1 | 208 | |
paulb@1 | 209 | raise NotImplementedError, "get_headers" |
paulb@1 | 210 | |
paulb@65 | 211 | def get_header_values(self, key): |
paulb@65 | 212 | |
paulb@65 | 213 | """ |
paulb@186 | 214 | Returns a list of all request header values associated with the given |
paulb@186 | 215 | 'key'. Note that according to RFC 2616, 'key' is treated as a |
paulb@186 | 216 | case-insensitive string. |
paulb@65 | 217 | """ |
paulb@65 | 218 | |
paulb@65 | 219 | raise NotImplementedError, "get_header_values" |
paulb@65 | 220 | |
paulb@1 | 221 | def get_content_type(self): |
paulb@1 | 222 | |
paulb@1 | 223 | """ |
paulb@186 | 224 | Returns the content type specified on the request, along with the |
paulb@186 | 225 | charset employed. |
paulb@1 | 226 | """ |
paulb@1 | 227 | |
paulb@1 | 228 | raise NotImplementedError, "get_content_type" |
paulb@1 | 229 | |
paulb@1 | 230 | def get_content_charsets(self): |
paulb@1 | 231 | |
paulb@1 | 232 | """ |
paulb@1 | 233 | Returns the character set preferences. |
paulb@1 | 234 | """ |
paulb@1 | 235 | |
paulb@1 | 236 | raise NotImplementedError, "get_content_charsets" |
paulb@1 | 237 | |
paulb@1 | 238 | def get_content_languages(self): |
paulb@1 | 239 | |
paulb@1 | 240 | """ |
paulb@186 | 241 | Returns extracted language information from the transaction. |
paulb@1 | 242 | """ |
paulb@1 | 243 | |
paulb@1 | 244 | raise NotImplementedError, "get_content_languages" |
paulb@1 | 245 | |
paulb@5 | 246 | def get_path(self): |
paulb@5 | 247 | |
paulb@5 | 248 | """ |
paulb@186 | 249 | Returns the entire path from the request. |
paulb@5 | 250 | """ |
paulb@5 | 251 | |
paulb@5 | 252 | raise NotImplementedError, "get_path" |
paulb@5 | 253 | |
paulb@162 | 254 | def get_path_without_query(self): |
paulb@162 | 255 | |
paulb@162 | 256 | """ |
paulb@186 | 257 | Returns the entire path from the request minus the query string. |
paulb@162 | 258 | """ |
paulb@162 | 259 | |
paulb@162 | 260 | raise NotImplementedError, "get_path_without_query" |
paulb@162 | 261 | |
paulb@1 | 262 | def get_path_info(self): |
paulb@1 | 263 | |
paulb@1 | 264 | """ |
paulb@186 | 265 | Returns the "path info" (the part of the URL after the resource name |
paulb@186 | 266 | handling the current request) from the request. |
paulb@1 | 267 | """ |
paulb@1 | 268 | |
paulb@1 | 269 | raise NotImplementedError, "get_path_info" |
paulb@1 | 270 | |
paulb@69 | 271 | def get_query_string(self): |
paulb@69 | 272 | |
paulb@69 | 273 | """ |
paulb@186 | 274 | Returns the query string from the path in the request. |
paulb@69 | 275 | """ |
paulb@69 | 276 | |
paulb@69 | 277 | raise NotImplementedError, "get_query_string" |
paulb@69 | 278 | |
paulb@69 | 279 | # Higher level request-related methods. |
paulb@69 | 280 | |
paulb@69 | 281 | def get_fields_from_path(self): |
paulb@69 | 282 | |
paulb@69 | 283 | """ |
paulb@249 | 284 | Extracts fields (or request parameters) from the path specified in the |
paulb@249 | 285 | transaction. The underlying framework may refuse to supply fields from |
paulb@249 | 286 | the path if handling a POST transaction. |
paulb@69 | 287 | |
paulb@71 | 288 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@71 | 289 | single value is associated with any given field name). |
paulb@69 | 290 | """ |
paulb@69 | 291 | |
paulb@69 | 292 | raise NotImplementedError, "get_fields_from_path" |
paulb@69 | 293 | |
paulb@167 | 294 | def get_fields_from_body(self, encoding=None): |
paulb@69 | 295 | |
paulb@69 | 296 | """ |
paulb@249 | 297 | Extracts fields (or request parameters) from the message body in the |
paulb@249 | 298 | transaction. The optional 'encoding' parameter specifies the character |
paulb@249 | 299 | encoding of the message body for cases where no such information is |
paulb@249 | 300 | available, but where the default encoding is to be overridden. |
paulb@69 | 301 | |
paulb@73 | 302 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@193 | 303 | single value is associated with any given field name). Each value is |
paulb@193 | 304 | either a Unicode object (representing a simple form field, for example) |
paulb@198 | 305 | or a plain string (representing a file upload form field, for example). |
paulb@69 | 306 | """ |
paulb@69 | 307 | |
paulb@69 | 308 | raise NotImplementedError, "get_fields_from_body" |
paulb@69 | 309 | |
paulb@249 | 310 | def get_fields(self, encoding=None): |
paulb@249 | 311 | |
paulb@249 | 312 | """ |
paulb@249 | 313 | Extracts fields (or request parameters) from both the path specified in |
paulb@249 | 314 | the transaction as well as the message body. The optional 'encoding' |
paulb@249 | 315 | parameter specifies the character encoding of the message body for cases |
paulb@249 | 316 | where no such information is available, but where the default encoding |
paulb@249 | 317 | is to be overridden. |
paulb@249 | 318 | |
paulb@249 | 319 | Returns a dictionary mapping field names to lists of values (even if a |
paulb@249 | 320 | single value is associated with any given field name). Each value is |
paulb@249 | 321 | either a Unicode object (representing a simple form field, for example) |
paulb@249 | 322 | or a plain string (representing a file upload form field, for example). |
paulb@249 | 323 | |
paulb@249 | 324 | Where a given field name is used in both the path and message body to |
paulb@249 | 325 | specify values, the values from both sources will be combined into a |
paulb@249 | 326 | single list associated with that field name. |
paulb@249 | 327 | """ |
paulb@249 | 328 | |
paulb@249 | 329 | raise NotImplementedError, "get_fields" |
paulb@249 | 330 | |
paulb@45 | 331 | def get_user(self): |
paulb@1 | 332 | |
paulb@1 | 333 | """ |
paulb@186 | 334 | Extracts user information from the transaction. |
paulb@115 | 335 | |
paulb@115 | 336 | Returns a username as a string or None if no user is defined. |
paulb@1 | 337 | """ |
paulb@1 | 338 | |
paulb@45 | 339 | raise NotImplementedError, "get_user" |
paulb@1 | 340 | |
paulb@98 | 341 | def get_cookies(self): |
paulb@98 | 342 | |
paulb@98 | 343 | """ |
paulb@186 | 344 | Obtains cookie information from the request. |
paulb@98 | 345 | |
paulb@98 | 346 | Returns a dictionary mapping cookie names to cookie objects. |
paulb@98 | 347 | """ |
paulb@98 | 348 | |
paulb@98 | 349 | raise NotImplementedError, "get_cookies" |
paulb@98 | 350 | |
paulb@104 | 351 | def get_cookie(self, cookie_name): |
paulb@104 | 352 | |
paulb@104 | 353 | """ |
paulb@186 | 354 | Obtains cookie information from the request. |
paulb@104 | 355 | |
paulb@104 | 356 | Returns a cookie object for the given 'cookie_name' or None if no such |
paulb@104 | 357 | cookie exists. |
paulb@104 | 358 | """ |
paulb@104 | 359 | |
paulb@104 | 360 | raise NotImplementedError, "get_cookie" |
paulb@104 | 361 | |
paulb@1 | 362 | # Response-related methods. |
paulb@1 | 363 | |
paulb@1 | 364 | def get_response_stream(self): |
paulb@1 | 365 | |
paulb@1 | 366 | """ |
paulb@186 | 367 | Returns the response stream for the transaction. |
paulb@1 | 368 | """ |
paulb@1 | 369 | |
paulb@1 | 370 | raise NotImplementedError, "get_response_stream" |
paulb@1 | 371 | |
paulb@252 | 372 | def get_response_stream_encoding(self): |
paulb@252 | 373 | |
paulb@252 | 374 | """ |
paulb@252 | 375 | Returns the response stream encoding. |
paulb@252 | 376 | """ |
paulb@252 | 377 | |
paulb@252 | 378 | raise NotImplementedError, "get_response_stream_encoding" |
paulb@252 | 379 | |
paulb@42 | 380 | def get_response_code(self): |
paulb@42 | 381 | |
paulb@42 | 382 | """ |
paulb@42 | 383 | Get the response code associated with the transaction. If no response |
paulb@42 | 384 | code is defined, None is returned. |
paulb@42 | 385 | """ |
paulb@42 | 386 | |
paulb@42 | 387 | raise NotImplementedError, "get_response_code" |
paulb@42 | 388 | |
paulb@42 | 389 | def set_response_code(self, response_code): |
paulb@42 | 390 | |
paulb@42 | 391 | """ |
paulb@42 | 392 | Set the 'response_code' using a numeric constant defined in the HTTP |
paulb@42 | 393 | specification. |
paulb@42 | 394 | """ |
paulb@42 | 395 | |
paulb@42 | 396 | raise NotImplementedError, "set_response_code" |
paulb@42 | 397 | |
paulb@67 | 398 | def set_header_value(self, header, value): |
paulb@49 | 399 | |
paulb@49 | 400 | """ |
paulb@49 | 401 | Set the HTTP 'header' with the given 'value'. |
paulb@49 | 402 | """ |
paulb@49 | 403 | |
paulb@67 | 404 | raise NotImplementedError, "set_header_value" |
paulb@49 | 405 | |
paulb@1 | 406 | def set_content_type(self, content_type): |
paulb@1 | 407 | |
paulb@1 | 408 | """ |
paulb@186 | 409 | Sets the 'content_type' for the response. |
paulb@1 | 410 | """ |
paulb@1 | 411 | |
paulb@1 | 412 | raise NotImplementedError, "set_content_type" |
paulb@1 | 413 | |
paulb@98 | 414 | # Higher level response-related methods. |
paulb@98 | 415 | |
paulb@98 | 416 | def set_cookie(self, cookie): |
paulb@98 | 417 | |
paulb@98 | 418 | """ |
paulb@186 | 419 | Stores the given 'cookie' object in the response. |
paulb@98 | 420 | """ |
paulb@98 | 421 | |
paulb@98 | 422 | raise NotImplementedError, "set_cookie" |
paulb@98 | 423 | |
paulb@98 | 424 | def set_cookie_value(self, name, value, path=None, expires=None): |
paulb@98 | 425 | |
paulb@98 | 426 | """ |
paulb@186 | 427 | Stores a cookie with the given 'name' and 'value' in the response. |
paulb@98 | 428 | |
paulb@98 | 429 | The optional 'path' is a string which specifies the scope of the cookie, |
paulb@98 | 430 | and the optional 'expires' parameter is a value compatible with the |
paulb@98 | 431 | time.time function, and indicates the expiry date/time of the cookie. |
paulb@98 | 432 | """ |
paulb@98 | 433 | |
paulb@98 | 434 | raise NotImplementedError, "set_cookie_value" |
paulb@98 | 435 | |
paulb@98 | 436 | def delete_cookie(self, cookie_name): |
paulb@98 | 437 | |
paulb@98 | 438 | """ |
paulb@186 | 439 | Adds to the response a request that the cookie with the given |
paulb@186 | 440 | 'cookie_name' be deleted/discarded by the client. |
paulb@98 | 441 | """ |
paulb@98 | 442 | |
paulb@98 | 443 | raise NotImplementedError, "delete_cookie" |
paulb@98 | 444 | |
paulb@183 | 445 | # Session-related methods. |
paulb@183 | 446 | |
paulb@183 | 447 | def get_session(self, create=1): |
paulb@183 | 448 | |
paulb@183 | 449 | """ |
paulb@186 | 450 | Gets a session corresponding to an identifier supplied in the |
paulb@186 | 451 | transaction. |
paulb@183 | 452 | |
paulb@183 | 453 | If no session has yet been established according to information |
paulb@183 | 454 | provided in the transaction then the optional 'create' parameter |
paulb@183 | 455 | determines whether a new session will be established. |
paulb@183 | 456 | |
paulb@183 | 457 | Where no session has been established and where 'create' is set to 0 |
paulb@183 | 458 | then None is returned. In all other cases, a session object is created |
paulb@183 | 459 | (where appropriate) and returned. |
paulb@183 | 460 | """ |
paulb@183 | 461 | |
paulb@183 | 462 | raise NotImplementedError, "get_session" |
paulb@183 | 463 | |
paulb@183 | 464 | def expire_session(self): |
paulb@183 | 465 | |
paulb@183 | 466 | """ |
paulb@186 | 467 | Expires any session established according to information provided in the |
paulb@186 | 468 | transaction. |
paulb@183 | 469 | """ |
paulb@183 | 470 | |
paulb@183 | 471 | raise NotImplementedError, "expire_session" |
paulb@183 | 472 | |
paulb@128 | 473 | # Application-specific methods. |
paulb@128 | 474 | |
paulb@128 | 475 | def set_user(self, username): |
paulb@128 | 476 | |
paulb@128 | 477 | """ |
paulb@128 | 478 | An application-specific method which sets the user information with |
paulb@128 | 479 | 'username' in the transaction. This affects subsequent calls to |
paulb@128 | 480 | 'get_user'. |
paulb@128 | 481 | """ |
paulb@128 | 482 | |
paulb@128 | 483 | raise NotImplementedError, "set_user" |
paulb@128 | 484 | |
paulb@1 | 485 | class Resource: |
paulb@1 | 486 | |
paulb@1 | 487 | "A generic resource interface." |
paulb@1 | 488 | |
paulb@3 | 489 | def respond(self, trans): |
paulb@3 | 490 | |
paulb@3 | 491 | """ |
paulb@3 | 492 | An application-specific method which performs activities on the basis of |
paulb@3 | 493 | the transaction object 'trans'. |
paulb@3 | 494 | """ |
paulb@3 | 495 | |
paulb@3 | 496 | raise NotImplementedError, "respond" |
paulb@1 | 497 | |
paulb@75 | 498 | class Authenticator: |
paulb@75 | 499 | |
paulb@75 | 500 | "A generic authentication component." |
paulb@75 | 501 | |
paulb@75 | 502 | def authenticate(self, trans): |
paulb@75 | 503 | |
paulb@75 | 504 | """ |
paulb@75 | 505 | An application-specific method which authenticates the sender of the |
paulb@75 | 506 | request described by the transaction object 'trans'. This method should |
paulb@75 | 507 | consider 'trans' to be read-only and not attempt to change the state of |
paulb@75 | 508 | the transaction. |
paulb@75 | 509 | |
paulb@75 | 510 | If the sender of the request is authenticated successfully, the result |
paulb@75 | 511 | of this method evaluates to true; otherwise the result of this method |
paulb@75 | 512 | evaluates to false. |
paulb@75 | 513 | """ |
paulb@75 | 514 | |
paulb@75 | 515 | raise NotImplementedError, "authenticate" |
paulb@75 | 516 | |
paulb@75 | 517 | def get_auth_type(self): |
paulb@75 | 518 | |
paulb@75 | 519 | """ |
paulb@75 | 520 | An application-specific method which returns the authentication type to |
paulb@75 | 521 | be used. An example value is 'Basic' which specifies HTTP basic |
paulb@75 | 522 | authentication. |
paulb@75 | 523 | """ |
paulb@75 | 524 | |
paulb@75 | 525 | raise NotImplementedError, "get_auth_type" |
paulb@75 | 526 | |
paulb@75 | 527 | def get_realm(self): |
paulb@75 | 528 | |
paulb@75 | 529 | """ |
paulb@75 | 530 | An application-specific method which returns the name of the realm for |
paulb@75 | 531 | which authentication is taking place. |
paulb@75 | 532 | """ |
paulb@75 | 533 | |
paulb@75 | 534 | raise NotImplementedError, "get_realm" |
paulb@75 | 535 | |
paulb@1 | 536 | # vim: tabstop=4 expandtab shiftwidth=4 |