Utilities for building WSGI commands.
libbe.command.serve_storage and libbe.command.serve_commands.
WSGI middleware for managing users
Changing passwords, usernames, etc.
Methods
admin(environ, start_response) | |
data_get_boolean(data, key[, default, source]) | |
data_get_id(data[, key, default, source]) | |
data_get_string(data, key[, default, source]) | |
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
is_head(environ) | |
log_request(environ[, status, bytes]) | |
ok_response(environ, start_response, content) | |
post_data(environ) | |
query_data(environ) |
WSGI middleware for handling user authentication.
Methods
authenticate(environ) | Handle user-authentication sent in the “Authorization” header. |
authfunc(environ, username, password) | |
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Handle user-authentication sent in the “Authorization” header.
This function implements Basic authentication as described in HTTP/1.0 specification [R3] . Do not use this module unless you are using SSL, as it transmits unencrypted passwords.
[R3] | http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#BasicAA |
Notes
Code based on authkit/authenticate/basic.py (c) 2005 Clark C. Evans. Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
Examples
>>> users = Users()
>>> users.add_user(User('Aladdin', 'Big Al', password='open sesame'))
>>> app = AuthenticationApp(app=None, realm='Dummy Realm', users=users)
>>> app.authenticate({'HTTP_AUTHORIZATION':'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='})
'Aladdin'
>>> app.authenticate({'HTTP_AUTHORIZATION':'Basic AAAAAAAAAAAAAAAAAAAAAAAAAA=='})
Translate BE-specific exceptions
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Some servers (e.g. cherrypy) eat app-raised exceptions.
Work around that by logging tracebacks by hand.
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Catch HandlerErrors and return HTTP error pages.
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Serve something over HTTP.
Use this as a base class to build commands that serve a web interface.
Methods
cleanup() | |
complete([argument, fragment]) | |
help(*args) | |
run([options, args]) | |
usage() |
Attributes
timeout |
Methods
MessageClass | |
address_string() | Return the client address formatted for logging. |
date_time_string([timestamp]) | Return the current date and time formatted for a message header. |
end_headers() | Send the blank line ending the MIME headers. |
finish() | |
get_environ() | |
get_stderr() | |
handle() | Handle a single HTTP request |
handle_one_request() | Handle a single HTTP request. |
log_date_time_string() | Return the current time formatted for logging. |
log_error(format, *args) | Log an error. |
log_message(format, *args) | |
log_request([code, size]) | Log an accepted request. |
parse_request() | Parse a request (internal). |
send_error(code[, message]) | Send and log an error reply. |
send_header(keyword, value) | Send a MIME header. |
send_response(code[, message]) | Send the response header and log the response code. |
setup() | |
version_string() | Return the server software version string. |
WSGI middleware that uppercases incoming HTTP headers.
From PEP 333, The start_response() Callable :
A reminder for server/gateway authors: HTTP header names are case-insensitive, so be sure to take that into consideration when examining application-supplied headers!
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Methods
from_string(string) | |
hash(password) | |
set_name(name) | |
set_password(password) | |
valid_login(password) |
Methods
add_user(user) | |
clear(() -> None. Remove all items from D.) | |
copy(() -> a shallow copy of D) | |
fromkeys(...) | v defaults to None. |
get((k[,d]) -> D[k] if k in D, ...) | |
has_key((k) -> True if D has a key k, else False) | |
items(() -> list of D’s (key, value) pairs, ...) | |
iteritems(() -> an iterator over the (key, ...) | |
iterkeys(() -> an iterator over the keys of D) | |
itervalues(...) | |
keys(() -> list of D’s keys) | |
load() | |
pop((k[,d]) -> v, ...) | If key is not found, d is returned if given, otherwise KeyError is raised |
popitem(() -> (k, v), ...) | 2-tuple; but raise KeyError if D is empty. |
save() | |
setdefault((k[,d]) -> D.get(k,d), ...) | |
update(([E, ...) | If E present and has a .keys() method, does: for k in E: D[k] = E[k] |
valid_login(uname, password) | |
values(() -> list of D’s values) | |
viewitems(...) | |
viewkeys(...) | |
viewvalues(...) |
Call into WSGI apps programmatically
Methods
getURL(app[, path, method, data, data_dict, ...]) | |
start_response(status, response_headers[, ...]) |
Useful WSGI utilities for handling URL delegation.
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Useful WSGI utilities for handling data (POST, QUERY) and returning responses.
Methods
data_get_boolean(data, key[, default, source]) | |
data_get_id(data[, key, default, source]) | |
data_get_string(data, key[, default, source]) | |
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
is_head(environ) | |
log_request(environ[, status, bytes]) | |
ok_response(environ, start_response, content) | |
post_data(environ) | |
query_data(environ) |
Utility class for WGSI middleware.
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Utility class for WGSI clients and middleware.
For details on WGSI, see PEP 333
Methods
error(environ, start_response, error, message) | Make it easy to call start_response for errors. |
log_request(environ[, status, bytes]) |
Make it easy to call start_response for errors.