base Package

controller Module

Contains functionality needed in every web interface

class galaxy.web.base.controller.BaseAPIController(app)[source]

Bases: galaxy.web.base.controller.BaseController

get_object(trans, id, class_name, check_ownership=False, check_accessible=False, deleted=None)[source]
not_implemented(trans, **kwd)[source]
validate_in_users_and_groups(trans, payload)[source]

For convenience, in_users and in_groups can be encoded IDs or emails/group names in the API.

class galaxy.web.base.controller.BaseController(app)[source]

Bases: object

Base class for Galaxy web application controllers.

decode_id(id)[source]
encode_all_ids(trans, rval, recursive=False)[source]

Encodes all integer values in the dict rval whose keys are ‘id’ or end with ‘_id’

It might be useful to turn this in to a decorator

get_class(class_name)[source]

Returns the class object that a string denotes. Without this method, we’d have to do eval(<class_name>).

get_group(trans, id, check_ownership=False, check_accessible=False, deleted=None)[source]
get_object(trans, id, class_name, check_ownership=False, check_accessible=False, deleted=None)[source]

Convenience method to get a model object with the specified checks.

get_role(trans, id, check_ownership=False, check_accessible=False, deleted=None)[source]
get_toolbox()[source]

Returns the application toolbox

get_user(trans, id, check_ownership=False, check_accessible=False, deleted=None)[source]
parse_filter_params(qdict, filter_attr_key='q', filter_value_key='qv', attr_op_split_char='-')[source]
parse_limit_offset(qdict)[source]
class galaxy.web.base.controller.BaseUIController(app)[source]

Bases: galaxy.web.base.controller.BaseController

get_object(trans, id, class_name, check_ownership=False, check_accessible=False, deleted=None)[source]
exception galaxy.web.base.controller.ControllerUnavailable[source]

Bases: exceptions.Exception

Deprecated: BaseController used to be available under the name Root

class galaxy.web.base.controller.CreatesApiKeysMixin[source]

Mixing centralizing logic for creating API keys for user objects.

Deprecated - please use api_keys.ApiKeyManager for new development.

create_api_key(trans, user)[source]
class galaxy.web.base.controller.CreatesUsersMixin[source]

Mixin centralizing logic for user creation between web and API controller.

Web controller handles additional features such e-mail subscription, activation, user forms, etc.... API created users are much more vanilla for the time being.

create_user(trans, email, username, password)[source]
class galaxy.web.base.controller.Datatype(extension, dtype, type_extension, mimetype, display_in_upload)[source]

Bases: object

Used for storing in-memory list of datatypes currently in the datatypes registry.

class galaxy.web.base.controller.ExportsHistoryMixin[source]
queue_history_export(trans, history, gzip=True, include_hidden=False, include_deleted=False)[source]
serve_ready_history_export(trans, jeha)[source]
class galaxy.web.base.controller.ImportsHistoryMixin[source]
queue_history_import(trans, archive_type, archive_source)[source]
galaxy.web.base.controller.Root

alias of BaseController

class galaxy.web.base.controller.SharableItemSecurityMixin[source]

Mixin for handling security for sharable items.

security_check(trans, item, check_ownership=False, check_accessible=False)[source]

Security checks for an item: checks if (a) user owns item or (b) item is accessible to user.

class galaxy.web.base.controller.SharableMixin[source]

Mixin for a controller that manages an item that can be shared.

create_item_slug(sa_session, item)[source]

Create/set item slug. Slug is unique among user’s importable items for item’s class. Returns true if item’s slug was set/changed; false otherwise.

display_by_username_and_slug(trans, username, slug)[source]

Display item by username and slug.

get_item(trans, id)[source]

Return item based on id.

get_item_content_async(trans, *args, **kwargs)[source]

Returns item content in HTML format.

Returns item’s name and link.

set_public_username(trans, *args, **kwargs)[source]

Set user’s public username and delegate to sharing()

set_slug_async(trans, *args, **kwargs)[source]
share(trans, *args, **kwargs)[source]

Handle sharing an item with a particular user.

sharing(trans, *args, **kwargs)[source]

Handle item sharing.

class galaxy.web.base.controller.UsesExtendedMetadataMixin[source]

Bases: galaxy.web.base.controller.SharableItemSecurityMixin

Mixin for getting and setting item extended metadata.

create_extended_metadata(trans, extmeta)[source]

Create/index an extended metadata object. The returned object is not associated with any items

delete_extended_metadata(trans, item)[source]
get_item_extended_metadata_obj(trans, item)[source]

Given an item object (such as a LibraryDatasetDatasetAssociation), find the object of the associated extended metadata

set_item_extended_metadata_obj(trans, item, extmeta_obj, check_writable=False)[source]
unset_item_extended_metadata_obj(trans, item, check_writable=False)[source]
class galaxy.web.base.controller.UsesFormDefinitionsMixin[source]

Mixin for controllers that use Galaxy form objects.

add_template(trans, cntrller, item_type, form_type, **kwd)[source]
build_form_id_select_field(trans, forms, selected_value='none')[source]
clean_field_contents(widgets, **kwd)[source]
delete_template(trans, cntrller, item_type, form_type, **kwd)[source]
edit_template(trans, cntrller, item_type, form_type, **kwd)[source]
edit_template_info(trans, cntrller, item_type, form_type, **kwd)[source]
field_param_values_ok(widget_name, widget_type, **kwd)[source]
get_all_forms(trans, all_versions=False, filter=None, form_type='All')[source]

Return all the latest forms from the form_definition_current table if all_versions is set to True. Otherwise return all the versions of all the forms from the form_definition table.

get_all_forms_by_type(trans, cntrller, form_type)[source]
get_form_values(trans, user, form_definition, **kwd)[source]

Returns the name:value dictionary containing all the form values

get_item_and_stuff(trans, item_type, **kwd)[source]
populate_widgets_from_kwd(trans, widgets, **kwd)[source]
save_widget_field(trans, field_obj, widget_name, **kwd)[source]
widget_fields_have_contents(widgets)[source]
class galaxy.web.base.controller.UsesLibraryMixin[source]
get_library(trans, id, check_ownership=False, check_accessible=True)[source]
class galaxy.web.base.controller.UsesLibraryMixinItems[source]

Bases: galaxy.web.base.controller.SharableItemSecurityMixin

can_current_user_add_to_library_item(trans, item)[source]
check_user_can_add_to_library_item(trans, item, check_accessible=True)[source]

Raise exception if user cannot add to the specified library item (i.e. Folder). Can set check_accessible to False if folder was loaded with this check.

copy_hda_to_library_folder(trans, hda, library_folder, roles=None, ldda_message='')[source]
get_library_dataset(trans, id, check_ownership=False, check_accessible=True)[source]
get_library_dataset_dataset_association(trans, id, check_ownership=False, check_accessible=True)[source]
get_library_folder(trans, id, check_ownership=False, check_accessible=True)[source]
class galaxy.web.base.controller.UsesQuotaMixin[source]

Bases: object

get_quota(trans, id, check_ownership=False, check_accessible=False, deleted=None)[source]
class galaxy.web.base.controller.UsesStoredWorkflowMixin[source]

Bases: galaxy.web.base.controller.SharableItemSecurityMixin, galaxy.model.item_attrs.UsesAnnotations

Mixin for controllers that use StoredWorkflow objects.

get_stored_workflow(trans, id, check_ownership=True, check_accessible=False)[source]

Get a StoredWorkflow from the database by id, verifying ownership.

get_stored_workflow_steps(trans, stored_workflow)[source]

Restores states for a stored workflow’s steps.

class galaxy.web.base.controller.UsesTagsMixin[source]

Bases: galaxy.web.base.controller.SharableItemSecurityMixin

get_tag_handler(trans)[source]
get_user_tags_used(trans, user=None)[source]

Return a list of distinct ‘user_tname:user_value’ strings that the given user has used.

user defaults to trans.user. Returns an empty list if no user is given and trans.user is anonymous.

set_tags_from_list(trans, item, new_tags_list, user=None)[source]
class galaxy.web.base.controller.UsesVisualizationMixin[source]

Bases: galaxy.web.base.controller.UsesLibraryMixinItems

Mixin for controllers that use Visualization objects.

add_visualization_revision(trans, visualization, config, title, dbkey)[source]

Adds a new VisualizationRevision to the given visualization with the given parameters and set its parent visualization’s latest_revision to the new revision.

create_visualization(trans, type, title='Untitled Visualization', slug=None, dbkey=None, annotation=None, config={}, save=True)[source]

Create visualiation and first revision.

get_hda(trans, dataset_id, check_ownership=True, check_accessible=False, check_state=True)[source]

Get an HDA object by id performing security checks using the current transaction.

get_hda_or_ldda(trans, hda_ldda, dataset_id)[source]

Returns either HDA or LDDA for hda/ldda and id combination.

get_new_track_config(trans, dataset)[source]

Returns track configuration dict for a dataset.

get_published_visualizations(trans, exclude_user=None, order_by=None, query_only=False)[source]

Return query or query results for published visualizations optionally excluding the user in exclude_user.

Set order_by to a column or list of columns to change the order returned. Defaults to DEFAULT_ORDER_BY. Set query_only to return just the query for further filtering or processing.

get_tool_def(trans, hda)[source]

Returns definition of an interactive tool for an HDA.

get_visualization(trans, id, check_ownership=True, check_accessible=False)[source]

Get a Visualization from the database by id, verifying ownership.

get_visualization_config(trans, visualization)[source]

Returns a visualization’s configuration. Only works for trackster visualizations right now.

get_visualization_dict(visualization)[source]

Return a set of detailed attributes for a visualization in dictionary form. The visualization’s latest_revision is returned in its own sub-dictionary. NOTE: that encoding ids isn’t done here should happen at the caller level.

get_visualization_revision_dict(revision)[source]

Return a set of detailed attributes for a visualization in dictionary form. NOTE: that encoding ids isn’t done here should happen at the caller level.

get_visualization_summary_dict(visualization)[source]

Return a set of summary attributes for a visualization in dictionary form. NOTE: that encoding ids isn’t done here should happen at the caller level.

get_visualizations_by_user(trans, user, order_by=None, query_only=False)[source]

Return query or query results of visualizations filtered by a user.

Set order_by to a column or list of columns to change the order returned. Defaults to DEFAULT_ORDER_BY. Set query_only to return just the query for further filtering or processing.

get_visualizations_shared_with_user(trans, user, order_by=None, query_only=False)[source]

Return query or query results for visualizations shared with the given user.

Set order_by to a column or list of columns to change the order returned. Defaults to DEFAULT_ORDER_BY. Set query_only to return just the query for further filtering or processing.

import_visualization(trans, id, user=None)[source]

Copy the visualization with the given id and associate the copy with the given user (defaults to trans.user).

Raises ItemAccessibilityException if user is not passed and the current user is anonymous, and if the visualization is not importable. Raises ItemDeletionException if the visualization has been deleted.

save_visualization(trans, config, type, id=None, title=None, dbkey=None, slug=None, annotation=None)[source]
viz_types = ['trackster']
galaxy.web.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