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 after start_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]
make_catching_iter(app_iter, environ, sr_checker)[source]
exception_handler(exc_info, environ)[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:
    handle_exception(
        sys.exc_info(), sys.stderr, html=False, ...other config...)

If you want to report, but not fully catch the exception, call raise after handle_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.

__init__(app, global_conf=None, limit=40)[source]
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.profile.get_func_list(stats, sel_list)[source]

Use ‘sel_list’ to select a list of functions to display.

galaxy.web.framework.middleware.profile.func_std_string(func_name)[source]

Match what old profile produced

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

__init__(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]
error(start_response, title='Access denied', message='Please contact your local Galaxy administrator.')[source]

galaxy.web.framework.middleware.request_id module

class galaxy.web.framework.middleware.request_id.RequestIDMiddleware(app, global_conf=None)[source]

Bases: object

A WSGI middleware that creates a unique ID for the request and puts it in the environment

__init__(app, global_conf=None)[source]

galaxy.web.framework.middleware.sentry module

raven.middleware

copyright:
  1. 2010-2012 by the Sentry Team, see AUTHORS for more details.
license:

BSD, see LICENSE for more details.

class galaxy.web.framework.middleware.sentry.Sentry(application, dsn)[source]

Bases: object

A WSGI middleware which will attempt to capture any uncaught exceptions and send them to Sentry.

__init__(application, dsn)[source]
handle_exception(environ)[source]

galaxy.web.framework.middleware.static module

class galaxy.web.framework.middleware.static.CacheableStaticURLParser(directory, cache_seconds=None)[source]

Bases: paste.urlparser.StaticURLParser

__init__(directory, cache_seconds=None)[source]
galaxy.web.framework.middleware.static.make_static(global_conf, document_root, cache_seconds=None)[source]

galaxy.web.framework.middleware.statsd module

Middleware for sending request statistics to statsd

class galaxy.web.framework.middleware.statsd.StatsdMiddleware(application, statsd_host, statsd_port, statsd_prefix)[source]

Bases: object

This middleware will log request durations to the configured statsd instance.

__init__(application, statsd_host, statsd_port, statsd_prefix)[source]

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"'
write_log(environ, method, req_uri, start, status, bytes)[source]
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.

galaxy.web.framework.middleware.xforwardedhost module

class galaxy.web.framework.middleware.xforwardedhost.XForwardedHostMiddleware(app, global_conf=None)[source]

Bases: object

A WSGI middleware that changes the HTTP host header in the WSGI environ based on the X-Forwarded-Host header IF found

__init__(app, global_conf=None)[source]