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 package

Galaxy web application framework

Submodules

galaxy.web.framework.base module

A simple WSGI application/framework.

galaxy.web.framework.base.server_starttime = 1726819436

time of the most recent server startup

class galaxy.web.framework.base.WebApplication[source]

Bases: object

A simple web application which maps requests to objects using routes, and to methods on those objects in the CherryPy style. Thus simple argument mapping in the CherryPy style occurs automatically, but more complicated encoding of arguments in the PATH_INFO can be performed with routes.

__init__()[source]

Create a new web application object. To actually connect some controllers use add_controller and add_route. Call finalize_config when all controllers and routes have been added and __call__ to handle a request (WSGI style).

add_ui_controller(controller_name, controller)[source]

Add a controller class to this application. A controller class has methods which handle web requests. To connect a URL to a controller’s method use add_route.

add_api_controller(controller_name, controller)[source]
add_route(route, **kwargs)[source]

Add a route to match a URL with a method. Accepts all keyword arguments of routes.Mapper.connect. Every route should result in at least a controller value which corresponds to one of the objects added with add_controller. It optionally may yield an action argument which will be used to locate the method to call on the controller. Additional arguments will be passed to the method as keyword args.

add_client_route(route, controller='root')[source]
set_transaction_factory(transaction_factory)[source]

Use the callable transaction_factory to create the transaction which will be passed to requests.

finalize_config()[source]

Call when application is completely configured and ready to serve requests

trace(**fields)[source]
handle_request(environ, start_response, body_renderer=None)[source]
make_body_iterable(trans, body)[source]
handle_controller_exception(e, trans, **kwargs)[source]

Allow handling of exceptions raised in controller methods.

class galaxy.web.framework.base.WSGIEnvironmentProperty(key, default='')[source]

Bases: object

Descriptor that delegates a property to a key in the environ member of the associated object (provides property style access to keys in the WSGI environment)

__init__(key, default='')[source]

Initialize self. See help(type(self)) for accurate signature.

class galaxy.web.framework.base.LazyProperty(func)[source]

Bases: object

Property that replaces itself with a calculated value the first time it is used.

__init__(func)[source]

Initialize self. See help(type(self)) for accurate signature.

galaxy.web.framework.base.lazy_property

alias of galaxy.web.framework.base.LazyProperty

class galaxy.web.framework.base.DefaultWebTransaction(environ)[source]

Bases: object

Wraps the state of a single web transaction (request/response cycle).

TODO: Provide hooks to allow application specific state to be included

in here.

__init__(environ)[source]

Initialize self. See help(type(self)) for accurate signature.

session[source]

Property that replaces itself with a calculated value the first time it is used.

class galaxy.web.framework.base.Request(environ)[source]

Bases: webob.request.Request

Encapsulates an HTTP request.

__init__(environ)[source]

Create a new request wrapping the WSGI environment environ

remote_host[source]

Property that replaces itself with a calculated value the first time it is used.

remote_hostname[source]

Property that replaces itself with a calculated value the first time it is used.

cookies[source]

Property that replaces itself with a calculated value the first time it is used.

base[source]

Property that replaces itself with a calculated value the first time it is used.

path[source]

Property that replaces itself with a calculated value the first time it is used.

browser_url[source]

Property that replaces itself with a calculated value the first time it is used.

remote_port

Descriptor that delegates a property to a key in the environ member of the associated object (provides property style access to keys in the WSGI environment)

protocol

Descriptor that delegates a property to a key in the environ member of the associated object (provides property style access to keys in the WSGI environment)

class galaxy.web.framework.base.Response[source]

Bases: object

Describes an HTTP response. Currently very simple since the actual body of the request is handled separately.

__init__()[source]

Create a new Response defaulting to HTML content and “200 OK” status

set_content_type(type_)[source]

Sets the Content-Type header

get_content_type()[source]
send_redirect(url)[source]

Send an HTTP redirect response to (target url)

wsgi_headeritems()[source]

Return headers in format appropriate for WSGI start_response

wsgi_status()[source]

Return status line in format appropriate for WSGI start_response

galaxy.web.framework.base.send_file(start_response, trans, body)[source]
galaxy.web.framework.base.iterate_file(fh)[source]

Progressively return chunks from file.

galaxy.web.framework.base.flatten(seq)[source]

Flatten a possible nested set of iterables

galaxy.web.framework.base.walk_controller_modules(package_name)[source]

galaxy.web.framework.decorators module

galaxy.web.framework.decorators.error(message)[source]
galaxy.web.framework.decorators.expose(func)[source]

Decorator: mark a function as ‘exposed’ and thus web accessible

galaxy.web.framework.decorators.json(func, pretty=False)[source]

Format the response as JSON and set the response content type to JSON_CONTENT_TYPE.

galaxy.web.framework.decorators.json_pretty(func)[source]

Indent and sort returned JSON.

galaxy.web.framework.decorators.require_login(verb='perform this action', use_panels=False, webapp='galaxy')[source]
galaxy.web.framework.decorators.require_admin(func)[source]
galaxy.web.framework.decorators.require_admin_message(config, user)[source]
galaxy.web.framework.decorators.do_not_cache(func)[source]

Sets cache-prevention headers for the request.

galaxy.web.framework.decorators.legacy_expose_api(func, to_json=True, user_required=True)[source]

Expose this function via the API.

galaxy.web.framework.decorators.legacy_expose_api_raw(func)[source]

Expose this function via the API but don’t dump the results to JSON.

galaxy.web.framework.decorators.legacy_expose_api_raw_anonymous(func)[source]

Expose this function via the API but don’t dump the results to JSON.

galaxy.web.framework.decorators.legacy_expose_api_anonymous(func, to_json=True)[source]

Expose this function via the API but don’t require a set user.

galaxy.web.framework.decorators.expose_api(func, to_json=True, user_required=True, user_or_session_required=True, handle_jsonp=True)[source]

Expose this function via the API.

galaxy.web.framework.decorators.format_return_as_json(rval, jsonp_callback=None, pretty=False)[source]

Formats a return value as JSON or JSONP if jsonp_callback is present.

Use pretty=True to return pretty printed json.

galaxy.web.framework.decorators.validation_error_to_message_exception(e)[source]
galaxy.web.framework.decorators.api_error_message(trans, **kwds)[source]
galaxy.web.framework.decorators.expose_api_anonymous(func, to_json=True)[source]

Expose this function via the API but don’t require a set user.

galaxy.web.framework.decorators.expose_api_anonymous_and_sessionless(func, to_json=True)[source]

Expose this function via the API but don’t require a user or a galaxy_session.

galaxy.web.framework.decorators.expose_api_raw(func)[source]
galaxy.web.framework.decorators.expose_api_raw_anonymous(func)[source]
galaxy.web.framework.decorators.expose_api_raw_anonymous_and_sessionless(func)[source]