galaxy.webapps.base package
Submodules
galaxy.webapps.base.api module
- class galaxy.webapps.base.api.GalaxyFileResponse(path: str | os.PathLike[str], status_code: int = 200, headers: Mapping[str, str] | None = None, media_type: str | None = None, background: BackgroundTask | None = None, filename: str | None = None, stat_result: stat_result | None = None, method: str | None = None, content_disposition_type: str = 'attachment')[source]
Bases:
FileResponse
Augments starlette FileResponse with x-accel-redirect/x-sendfile and byte-range handling.
- __init__(path: str | os.PathLike[str], status_code: int = 200, headers: Mapping[str, str] | None = None, media_type: str | None = None, background: BackgroundTask | None = None, filename: str | None = None, stat_result: stat_result | None = None, method: str | None = None, content_disposition_type: str = 'attachment') None [source]
- galaxy.webapps.base.api.get_error_response_for_request(request: Request, exc: MessageException) JSONResponse [source]
galaxy.webapps.base.controller module
Contains functionality needed in every web interface
- exception galaxy.webapps.base.controller.HTTPBadRequest(detail=None, headers=None, comment=None, body_template=None, json_formatter=None, **kw)[source]
Bases:
HTTPClientError
,HTTPBadRequest
- explanation = 'The server could not comply with the request since it is either malformed or otherwise incorrect.'
- class galaxy.webapps.base.controller.SharableMixin[source]
Bases:
object
Mixin for a controller that manages an item that can be shared.
- slug_builder = <galaxy.managers.sharable.SlugBuilder object>
Handle sharing an item with a particular user.
- galaxy.webapps.base.controller.sort_by_attr(seq, attr)[source]
Sort the sequence of objects by object’s attribute Arguments: seq - the list or any sequence (including immutable one) of objects to sort. attr - the name of attribute to sort by
- galaxy.webapps.base.controller.url_for(*args, **kwargs) str
Tries to resolve the URL using the routes module.
This only works in a WSGI app so a deprecation message is returned when running an ASGI app.
- class galaxy.webapps.base.controller.UsesExtendedMetadataMixin[source]
Bases:
SharableItemSecurityMixin
Mixin for getting and setting item extended metadata.
- get_item_extended_metadata_obj(trans, item)[source]
Given an item object (such as a LibraryDatasetDatasetAssociation), find the object of the associated extended metadata
- class galaxy.webapps.base.controller.UsesFormDefinitionsMixin[source]
Bases:
object
Mixin for controllers that use Galaxy form objects.
galaxy.webapps.base.webapp module
- class galaxy.webapps.base.webapp.WebApplication(galaxy_app: MinimalApp, session_cookie: str = 'galaxysession', name: str | None = None)[source]
Bases:
WebApplication
Base WSGI application instantiated for all Galaxy webapps.
A web application that:
adds API and UI controllers by scanning given directories and importing all modules found there.
has a security object.
builds mako template lookups.
generates GalaxyWebTransactions.
- __init__(galaxy_app: MinimalApp, session_cookie: str = 'galaxysession', name: str | None = None) None [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).
- build_apispec()[source]
Traverse all route paths starting with “api” and create an APISpec instance.
- handle_controller_exception(e, trans, method, **kwargs)[source]
Allow handling of exceptions raised in controller methods.
- transaction_chooser(environ, galaxy_app: BasicSharedApp, session_cookie: str)[source]
- galaxy.webapps.base.webapp.url_builder(*args, **kwargs) str [source]
Wrapper around the WSGI version of the function for reversing URLs.
- class galaxy.webapps.base.webapp.GalaxyWebTransaction(environ: Dict[str, Any], app: BasicSharedApp, webapp: WebApplication, session_cookie: str | None = None)[source]
Bases:
DefaultWebTransaction
,ProvidesHistoryContext
Encapsulates web transaction specific state for the Galaxy application (specifically the user’s “cookie” session and history)
- __init__(environ: Dict[str, Any], app: BasicSharedApp, webapp: WebApplication, session_cookie: str | None = None) None [source]
- property app
Provide access to the Galaxy
app
object.
- property url_builder
Provide access to Galaxy URLs (if available).
- Parameters:
qualified (bool) – if True, the fully qualified URL is returned, else a relative URL is returned (default False).
- set_cors_headers()[source]
Allow CORS requests if configured to do so by echoing back the request’s ‘Origin’ header (if any) as the response header ‘Access-Control-Allow-Origin’
Preflight OPTIONS requests to the API work by routing all OPTIONS requests to a single method in the authenticate API (options method), setting CORS headers, and responding OK.
NOTE: raising some errors (such as httpexceptions), will remove the header (e.g. client will get both CORS error and 404 inside that)
- property user
Return the current user if logged in or None.
- property cookie_path
- handle_user_login(user)[source]
- Login a new user (possibly newly created)
do some ‘system’ checks (if any) for this user
create a new session
associate new session with user
if old session had a history and it was not associated with a user, associate it with the new session, otherwise associate the current session’s history with the user
add the disk usage of the current session to the user’s total disk usage
- handle_user_logout(logout_all=False)[source]
- Logout the current user:
invalidate the current session
create a new session with no user associated
- get_history(create=False, most_recent=False)[source]
Load the current history.
If that isn’t available, we find the most recently updated history.
If that isn’t available, we get or create the default history.
Transactions will not always have an active history (API requests), so None is a valid response.
- property history
Provide access to the user’s current history model object.
- Return type:
Optional[galaxy.model.History]
- get_or_create_default_history()[source]
Gets or creates a default history and associates it with the current session.
- new_history(name=None)[source]
Create a new history and associate it with the current session and its associated user (if set).
- template_context
Property that replaces itself with a calculated value the first time it is used.
- set_message(message, type=None)[source]
Convenience method for setting the ‘message’ and ‘message_type’ element of the template context.
- get_message()[source]
Convenience method for getting the ‘message’ element of the template context.
- show_message(message, type='info', refresh_frames=None, cont=None, use_panels=False, active_view='')[source]
Convenience method for displaying a simple page with a single message.
- type: one of “error”, “warning”, “info”, or “done”; determines the
type of dialog box and icon displayed with the message
- refresh_frames: names of frames in the interface that should be
refreshed when the message is displayed
- show_error_message(message, refresh_frames=None, use_panels=False, active_view='')[source]
Convenience method for displaying an error message. See show_message.
- show_ok_message(message, refresh_frames=None, use_panels=False, active_view='')[source]
Convenience method for displaying an ok message. See show_message.
- show_warn_message(message, refresh_frames=None, use_panels=False, active_view='')[source]
Convenience method for displaying an warn message. See show_message.
- property session_csrf_token
- galaxy.webapps.base.webapp.create_new_session(trans, prev_galaxy_session=None, user_for_new_session=None)[source]
Create a new GalaxySession for this request, possibly with a connection to a previous session (in prev_galaxy_session) and an existing user (in user_for_new_session).
Caller is responsible for flushing the returned session.