Reduce config duplication related to setting up webapps.

And apply some fixes/improvements for galaxy back into tool shed and reports.
This commit is contained in:
John Chilton
2015-01-30 15:54:02 -05:00
parent 4104759bf0
commit a8b5923026
5 changed files with 35 additions and 67 deletions
+7 -7
View File
@@ -64,10 +64,10 @@ mailing_join_addr = galaxy-user-join@bx.psu.edu
use_new_layout = true
# Serving static files (needed if running standalone)
static_enabled = True
static_cache_time = 360
static_dir = %(here)s/static/
static_images_dir = %(here)s/static/images
static_favicon_dir = %(here)s/static/favicon.ico
static_scripts_dir = %(here)s/static/scripts/
static_style_dir = %(here)s/static/june_2007_style/blue
# static_enabled = True
# static_cache_time = 360
# static_dir = %(here)s/static/
# static_images_dir = %(here)s/static/images
# static_favicon_dir = %(here)s/static/favicon.ico
# static_scripts_dir = %(here)s/static/scripts/
# static_style_dir = %(here)s/static/june_2007_style/blue
+23
View File
@@ -814,3 +814,26 @@ class GalaxyWebTransaction( base.DefaultWebTransaction,
template = Template( source=template_string,
searchList=[context or kwargs, dict(caller=self)] )
return str(template)
def build_url_map( app, global_conf, local_conf ):
from paste.urlmap import URLMap
from galaxy.web.framework.middleware.static import CacheableStaticURLParser as Static
urlmap = URLMap()
# Merge the global and local configurations
conf = global_conf.copy()
conf.update(local_conf)
# Get cache time in seconds
cache_time = conf.get( "static_cache_time", None )
if cache_time is not None:
cache_time = int( cache_time )
# Send to dynamic app by default
urlmap["/"] = app
# Define static mappings from config
urlmap["/static"] = Static( conf.get( "static_dir", "./static/" ), cache_time )
urlmap["/images"] = Static( conf.get( "static_images_dir", "./static/images" ), cache_time )
urlmap["/static/scripts"] = Static( conf.get( "static_scripts_dir", "./static/scripts/" ), cache_time )
urlmap["/static/style"] = Static( conf.get( "static_style_dir", "./static/style/blue" ), cache_time )
urlmap["/favicon.ico"] = Static( conf.get( "static_favicon_dir", "./static/favicon.ico" ), cache_time )
urlmap["/robots.txt"] = Static( conf.get( "static_robots_txt", "./static/robots.txt" ), cache_time )
return urlmap, cache_time
+1 -19
View File
@@ -610,26 +610,8 @@ def wrap_in_middleware( app, global_conf, **local_conf ):
return app
def wrap_in_static( app, global_conf, plugin_frameworks=None, **local_conf ):
from paste.urlmap import URLMap
from galaxy.web.framework.middleware.static import CacheableStaticURLParser as Static
urlmap = URLMap()
# Merge the global and local configurations
conf = global_conf.copy()
conf.update(local_conf)
# Get cache time in seconds
cache_time = conf.get( "static_cache_time", None )
if cache_time is not None:
cache_time = int( cache_time )
# Send to dynamic app by default
urlmap["/"] = app
# Define static mappings from config
urlmap["/static"] = Static( conf.get( "static_dir", "./static/" ), cache_time )
urlmap["/images"] = Static( conf.get( "static_images_dir", "./static/images" ), cache_time )
urlmap["/static/scripts"] = Static( conf.get( "static_scripts_dir", "./static/scripts/" ), cache_time )
urlmap["/static/style"] = Static( conf.get( "static_style_dir", "./static/style/blue" ), cache_time )
urlmap["/favicon.ico"] = Static( conf.get( "static_favicon_dir", "./static/favicon.ico" ), cache_time )
urlmap["/robots.txt"] = Static( conf.get( "static_robots_txt", "./static/robots.txt" ), cache_time )
urlmap, cache_time = galaxy.web.framework.webapp.build_url_map( app, global_conf, local_conf )
# wrap any static dirs for plugins
plugin_frameworks = plugin_frameworks or []
for framework in plugin_frameworks:
+2 -20
View File
@@ -62,7 +62,7 @@ def app_factory( global_conf, **kwargs ):
# Wrap the webapp in some useful middleware
if kwargs.get( 'middleware', True ):
webapp = wrap_in_middleware( webapp, global_conf, **kwargs )
if kwargs.get( 'static_enabled', True ):
if asbool( kwargs.get( 'static_enabled', True ) ):
webapp = wrap_in_static( webapp, global_conf, **kwargs )
# Close any pooled database connections before forking
try:
@@ -135,25 +135,7 @@ def wrap_in_middleware( app, global_conf, **local_conf ):
return app
def wrap_in_static( app, global_conf, **local_conf ):
from paste.urlmap import URLMap
from galaxy.web.framework.middleware.static import CacheableStaticURLParser as Static
urlmap = URLMap()
# Merge the global and local configurations
conf = global_conf.copy()
conf.update(local_conf)
# Get cache time in seconds
cache_time = conf.get( "static_cache_time", None )
if cache_time is not None:
cache_time = int( cache_time )
# Send to dynamic app by default
urlmap["/"] = app
# Define static mappings from config
urlmap["/static"] = Static( conf.get( "static_dir" ), cache_time )
urlmap["/images"] = Static( conf.get( "static_images_dir" ), cache_time )
urlmap["/static/scripts"] = Static( conf.get( "static_scripts_dir" ), cache_time )
urlmap["/static/style"] = Static( conf.get( "static_style_dir" ), cache_time )
urlmap["/favicon.ico"] = Static( conf.get( "static_favicon_dir" ), cache_time )
# URL mapper becomes the root webapp
urlmap, _ = galaxy.web.framework.webapp.build_url_map( app, global_conf, local_conf )
return urlmap
def build_template_error_formatters():
+2 -21
View File
@@ -134,7 +134,7 @@ def app_factory( global_conf, **kwargs ):
# Wrap the webapp in some useful middleware
if kwargs.get( 'middleware', True ):
webapp = wrap_in_middleware( webapp, global_conf, **kwargs )
if kwargs.get( 'static_enabled', True ):
if asbool( kwargs.get( 'static_enabled', True ) ):
webapp = wrap_in_static( webapp, global_conf, **kwargs )
# Close any pooled database connections before forking
try:
@@ -219,26 +219,7 @@ def wrap_in_middleware( app, global_conf, **local_conf ):
return app
def wrap_in_static( app, global_conf, **local_conf ):
from paste.urlmap import URLMap
from galaxy.web.framework.middleware.static import CacheableStaticURLParser as Static
urlmap = URLMap()
# Merge the global and local configurations
conf = global_conf.copy()
conf.update(local_conf)
# Get cache time in seconds
cache_time = conf.get( "static_cache_time", None )
if cache_time is not None:
cache_time = int( cache_time )
# Send to dynamic app by default
urlmap["/"] = app
# Define static mappings from config
urlmap["/static"] = Static( conf.get( "static_dir", "./static/" ), cache_time )
urlmap["/images"] = Static( conf.get( "static_images_dir", "./static/images" ), cache_time )
urlmap["/static/scripts"] = Static( conf.get( "static_scripts_dir", "./static/scripts/" ), cache_time )
urlmap["/static/style"] = Static( conf.get( "static_style_dir", "./static/style/blue" ), cache_time )
urlmap["/favicon.ico"] = Static( conf.get( "static_favicon_dir", "./static/favicon.ico" ), cache_time )
urlmap["/robots.txt"] = Static( conf.get( "static_robots_txt", "./static/robots.txt" ), cache_time )
# URL mapper becomes the root webapp
urlmap, _ = galaxy.web.framework.webapp.build_url_map( app, global_conf, local_conf )
return urlmap
def build_template_error_formatters():