Warning
This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
galaxy.web.framework.middleware package¶
WSGI Middleware.
Submodules¶
galaxy.web.framework.middleware.error module¶
Error handler middleware
When an exception is thrown from the wrapper application, this logs the exception and displays an error page.
- class galaxy.web.framework.middleware.error.ErrorMiddleware(application, global_conf=None, debug=<NoDefault>, error_email=None, error_log=None, show_exceptions_in_wsgi_errors=<NoDefault>, from_address=None, smtp_server=None, smtp_username=None, smtp_password=None, smtp_use_tls=False, error_subject_prefix=None, error_message=None, xmlhttp_key=None)[source]¶
Bases:
object
Error handling middleware
Usage:
error_catching_wsgi_app = ErrorMiddleware(wsgi_app)
Settings:
debug
:If true, then tracebacks will be shown in the browser.
error_email
:an email address (or list of addresses) to send exception reports to
error_log
:a filename to append tracebacks to
show_exceptions_in_wsgi_errors
:If true, then errors will be printed to
wsgi.errors
(frequently a server error log, or stderr).from_address
,smtp_server
,error_subject_prefix
,smtp_username
,smtp_password
,smtp_use_tls
:variables to control the emailed exception reports
error_message
:When debug mode is off, the error message to show to users.
xmlhttp_key
:When this key (default
_
) is in the request GET variables (not POST!), expect that this is an XMLHttpRequest, and the response should be more minimal; it should not be a complete HTML page.
Environment Configuration:
paste.throw_errors
:If this setting in the request environment is true, then this middleware is disabled. This can be useful in a testing situation where you don’t want errors to be caught and transformed.
paste.expected_exceptions
:When this middleware encounters an exception listed in this environment variable and when the
start_response
has not yet occurred, the exception will be re-raised instead of being caught. This should generally be set by middleware that may (but probably shouldn’t be) installed above this middleware, and wants to get certain exceptions. Exceptions raised afterstart_response
have been called are always caught since by definition they are no longer expected.
- __init__(application, global_conf=None, debug=<NoDefault>, error_email=None, error_log=None, show_exceptions_in_wsgi_errors=<NoDefault>, from_address=None, smtp_server=None, smtp_username=None, smtp_password=None, smtp_use_tls=False, error_subject_prefix=None, error_message=None, xmlhttp_key=None)[source]¶
- galaxy.web.framework.middleware.error.handle_exception(exc_info, error_stream, html=True, debug_mode=False, error_email=None, error_log=None, show_exceptions_in_wsgi_errors=False, error_email_from='errors@localhost', smtp_server='localhost', smtp_username=None, smtp_password=None, smtp_use_tls=False, error_subject_prefix='', error_message=None, simple_html_error=False, environ=None)[source]¶
For exception handling outside of a web context
Use like:
import sys from paste.exceptions.errormiddleware import handle_exception try: do stuff except Exception: handle_exception( sys.exc_info(), sys.stderr, html=False, ...other config...)
If you want to report, but not fully catch the exception, call
raise
afterhandle_exception
, which (when given no argument) will reraise the exception.
galaxy.web.framework.middleware.profile module¶
Middleware that profiles the request with cProfile and displays profiling information at the bottom of each page.
- class galaxy.web.framework.middleware.profile.ProfileMiddleware(app, global_conf=None, limit=40)[source]¶
Bases:
object
Middleware that profiles all requests.
All HTML pages will have profiling information appended to them. The data is isolated to that single request, and does not include data from previous requests.
- galaxy.web.framework.middleware.profile.pstats_as_html(stats, *sel_list)[source]¶
Return an HTML representation of a pstats.Stats object.
galaxy.web.framework.middleware.remoteuser module¶
Middleware for handling $REMOTE_USER if use_remote_user is enabled.
- class galaxy.web.framework.middleware.remoteuser.RemoteUser(app, maildomain=None, display_servers=None, admin_users=None, single_user=None, remote_user_header=None, remote_user_secret_header=None, normalize_remote_user_email=False)[source]¶
Bases:
object
galaxy.web.framework.middleware.request_id module¶
galaxy.web.framework.middleware.sqldebug module¶
Per-request SQL debugging middleware.
galaxy.web.framework.middleware.static module¶
galaxy.web.framework.middleware.statsd module¶
Middleware for sending request statistics to statsd.
galaxy.web.framework.middleware.translogger module¶
Middleware for logging requests, using Apache combined log format
- class galaxy.web.framework.middleware.translogger.TransLogger(application, logger=None, format=None, logging_level=20, logger_name='wsgi', setup_console_handler=True, set_logger_level=10)[source]¶
Bases:
object
This logging middleware will log all requests as they go through. They are, by default, sent to a logger named
'wsgi'
at the INFO level.If
setup_console_handler
is true, then messages for the named logger will be sent to the console.- __init__(application, logger=None, format=None, logging_level=20, logger_name='wsgi', setup_console_handler=True, set_logger_level=10)[source]¶
- format = '%(REMOTE_ADDR)s - %(REMOTE_USER)s [%(time)s] "%(REQUEST_METHOD)s %(REQUEST_URI)s %(HTTP_VERSION)s" %(status)s %(bytes)s "%(HTTP_REFERER)s" "%(HTTP_USER_AGENT)s"'¶
- galaxy.web.framework.middleware.translogger.make_filter(app, global_conf, logger_name='wsgi', format=None, logging_level=20, setup_console_handler=True, set_logger_level=10)[source]¶
This logging middleware will log all requests as they go through. They are, by default, sent to a logger named
'wsgi'
at the INFO level.If
setup_console_handler
is true, then messages for the named logger will be sent to the console.