Example #1
0
def app_factory(global_conf, load_app_kwds=None, **kwargs):
    """Return a wsgi application serving the root object"""
    # Create the Galaxy application unless passed in
    load_app_kwds = load_app_kwds or {}
    kwargs = load_app_properties(kwds=kwargs, **load_app_kwds)
    if 'app' in kwargs:
        app = kwargs.pop('app')
    else:
        from galaxy.webapps.reports.app import UniverseApplication
        app = UniverseApplication(global_conf=global_conf, **kwargs)
    atexit.register(app.shutdown)
    # Create the universe WSGI application
    webapp = ReportsWebApplication(app,
                                   session_cookie='galaxyreportssession',
                                   name="reports")
    add_ui_controllers(webapp, app)
    # These two routes handle our simple needs at the moment
    webapp.add_route('/{controller}/{action}',
                     controller="root",
                     action='index')
    webapp.add_route('/{action}', controller='root', action='index')
    webapp.finalize_config()
    # Wrap the webapp in some useful middleware
    if kwargs.get('middleware', True):
        webapp = wrap_in_middleware(webapp, global_conf, app.application_stack,
                                    **kwargs)
    if asbool(kwargs.get('static_enabled', True)):
        webapp = wrap_if_allowed(webapp,
                                 app.application_stack,
                                 build_url_map,
                                 args=(global_conf, ),
                                 kwargs=kwargs)
    return webapp
Example #2
0
def app_factory(global_conf, load_app_kwds={}, **kwargs):
    """Return a wsgi application serving the root object"""
    # Create the Galaxy application unless passed in
    kwargs = load_app_properties(kwds=kwargs, **load_app_kwds)
    if 'app' in kwargs:
        app = kwargs.pop('app')
    else:
        from galaxy.webapps.reports.app import UniverseApplication
        app = UniverseApplication(global_conf=global_conf, **kwargs)
    atexit.register(app.shutdown)
    # Create the universe WSGI application
    webapp = ReportsWebApplication(app,
                                   session_cookie='galaxyreportssession',
                                   name="reports")
    add_ui_controllers(webapp, app)
    # These two routes handle our simple needs at the moment
    webapp.add_route('/{controller}/{action}',
                     controller="root",
                     action='index')
    webapp.add_route('/{action}', controller='root', action='index')
    webapp.finalize_config()
    # Wrap the webapp in some useful middleware
    if kwargs.get('middleware', True):
        webapp = wrap_in_middleware(webapp, global_conf, app.application_stack,
                                    **kwargs)
    if asbool(kwargs.get('static_enabled', True)):
        webapp = wrap_if_allowed(webapp,
                                 app.application_stack,
                                 wrap_in_static,
                                 args=(global_conf, ),
                                 kwargs=kwargs)
    # Close any pooled database connections before forking
    try:
        galaxy.model.mapping.metadata.bind.dispose()
    except Exception:
        log.exception(
            "Unable to dispose of pooled galaxy model database connections.")
    # Return
    return webapp
Example #3
0
def app_factory(global_conf, load_app_kwds=None, **kwargs):
    """Return a wsgi application serving the root object"""
    # Create the Galaxy tool shed application unless passed in
    load_app_kwds = load_app_kwds or {}
    kwargs = load_app_properties(kwds=kwargs,
                                 config_prefix='TOOL_SHED_CONFIG_',
                                 **load_app_kwds)
    if 'app' in kwargs:
        app = kwargs.pop('app')
    else:
        try:
            from tool_shed.webapp.app import UniverseApplication
            app = UniverseApplication(global_conf=global_conf, **kwargs)
        except Exception:
            import traceback
            import sys
            traceback.print_exc()
            sys.exit(1)
    atexit.register(app.shutdown)
    # Create the universe WSGI application
    webapp = CommunityWebApplication(app,
                                     session_cookie='galaxycommunitysession',
                                     name="tool_shed")
    add_ui_controllers(webapp, app)
    webapp.add_route('/view/{owner}',
                     controller='repository',
                     action='sharable_owner')
    webapp.add_route('/view/{owner}/{name}',
                     controller='repository',
                     action='sharable_repository')
    webapp.add_route('/view/{owner}/{name}/{changeset_revision}',
                     controller='repository',
                     action='sharable_repository_revision')
    # Handle displaying tool help images and README file images for tools contained in repositories.
    webapp.add_route(
        '/repository/static/images/{repository_id}/{image_file:.+?}',
        controller='repository',
        action='display_image_in_repository',
        repository_id=None,
        image_file=None)
    webapp.add_route('/{controller}/{action}', action='index')
    webapp.add_route('/{action}', controller='repository', action='index')
    # Enable 'hg clone' functionality on repos by letting hgwebapp handle the request
    webapp.add_route('/repos/*path_info',
                     controller='hg',
                     action='handle_request',
                     path_info='/')
    # Add the web API.  # A good resource for RESTful services - https://routes.readthedocs.io/en/latest/restful.html
    webapp.add_api_controllers('tool_shed.webapp.api', app)
    webapp.mapper.connect('api_key_retrieval',
                          '/api/authenticate/baseauth/',
                          controller='authenticate',
                          action='get_tool_shed_api_key',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect('group',
                          '/api/groups/',
                          controller='groups',
                          action='index',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect('group',
                          '/api/groups/',
                          controller='groups',
                          action='create',
                          conditions=dict(method=["POST"]))
    webapp.mapper.connect('group',
                          '/api/groups/{encoded_id}',
                          controller='groups',
                          action='show',
                          conditions=dict(method=["GET"]))
    webapp.mapper.resource('category',
                           'categories',
                           controller='categories',
                           name_prefix='category_',
                           path_prefix='/api',
                           parent_resources=dict(member_name='category',
                                                 collection_name='categories'))
    webapp.mapper.connect('repositories_in_category',
                          '/api/categories/{category_id}/repositories',
                          controller='categories',
                          action='get_repositories',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect('show_updates_for_repository',
                          '/api/repositories/updates',
                          controller='repositories',
                          action='updates',
                          conditions=dict(method=["GET"]))
    webapp.mapper.resource('repository',
                           'repositories',
                           controller='repositories',
                           collection={
                               'add_repository_registry_entry': 'POST',
                               'get_repository_revision_install_info': 'GET',
                               'get_ordered_installable_revisions': 'GET',
                               'get_installable_revisions': 'GET',
                               'remove_repository_registry_entry': 'POST',
                               'repository_ids_for_setting_metadata': 'GET',
                               'reset_metadata_on_repositories': 'POST',
                               'reset_metadata_on_repository': 'POST'
                           },
                           name_prefix='repository_',
                           path_prefix='/api',
                           parent_resources=dict(
                               member_name='repository',
                               collection_name='repositories'))
    webapp.mapper.resource('repository_revision',
                           'repository_revisions',
                           member={
                               'repository_dependencies': 'GET',
                               'export': 'POST'
                           },
                           controller='repository_revisions',
                           name_prefix='repository_revision_',
                           path_prefix='/api',
                           parent_resources=dict(
                               member_name='repository_revision',
                               collection_name='repository_revisions'))
    webapp.mapper.resource('user',
                           'users',
                           controller='users',
                           name_prefix='user_',
                           path_prefix='/api',
                           parent_resources=dict(member_name='user',
                                                 collection_name='users'))
    webapp.mapper.connect('update_repository',
                          '/api/repositories/{id}',
                          controller='repositories',
                          action='update',
                          conditions=dict(method=["PATCH", "PUT"]))
    webapp.mapper.connect('repository_create_changeset_revision',
                          '/api/repositories/{id}/changeset_revision',
                          controller='repositories',
                          action='create_changeset_revision',
                          conditions=dict(method=["POST"]))
    webapp.mapper.connect('repository_get_metadata',
                          '/api/repositories/{id}/metadata',
                          controller='repositories',
                          action='metadata',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect('repository_show_tools',
                          '/api/repositories/{id}/{changeset}/show_tools',
                          controller='repositories',
                          action='show_tools',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect('create_repository',
                          '/api/repositories',
                          controller='repositories',
                          action='create',
                          conditions=dict(method=["POST"]))
    webapp.mapper.connect('tools',
                          '/api/tools',
                          controller='tools',
                          action='index',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect('json',
                          '/api/tools/json',
                          controller='tools',
                          action='json',
                          conditions=dict(method=["GET"]))
    webapp.mapper.connect("version",
                          "/api/version",
                          controller="configuration",
                          action="version",
                          conditions=dict(method=["GET"]))

    webapp.finalize_config()
    # Wrap the webapp in some useful middleware
    if kwargs.get('middleware', True):
        webapp = wrap_in_middleware(webapp, global_conf, app.application_stack,
                                    **kwargs)
    if asbool(kwargs.get('static_enabled', True)):
        webapp = wrap_if_allowed(webapp,
                                 app.application_stack,
                                 wrap_in_static,
                                 args=(global_conf, ),
                                 kwargs=kwargs)
    # Close any pooled database connections before forking
    try:
        tool_shed.webapp.model.mapping.metadata.bind.dispose()
    except Exception:
        log.exception(
            "Unable to dispose of pooled tool_shed model database connections."
        )
    # Return
    return webapp