Import patch contributed by Jim Johnson that supports sub directories in extra_files_path for displaying and downloading.

"Numerous applications create html files with a directory hierarchy. I\'m including a patch support the display and download of datasets that include subdirs in their extra_files_path."
This commit is contained in:
Daniel Blankenberg
2011-06-02 11:46:49 -04:00
parent c229b70b4c
commit 90aeffb5e6
2 changed files with 14 additions and 11 deletions
+2
View File
@@ -94,6 +94,8 @@ def app_factory( global_conf, **kwargs ):
webapp.add_route( '/async/:tool_id/:data_id/:data_secret', controller='async', action='index', tool_id=None, data_id=None, data_secret=None )
webapp.add_route( '/:controller/:action', action='index' )
webapp.add_route( '/:action', controller='root', action='index' )
# allow for subdirectories in extra_files_path
webapp.add_route( '/datasets/:dataset_id/display/{filename:.+?}', controller='dataset', action='display', dataset_id=None, filename=None)
webapp.add_route( '/datasets/:dataset_id/:action/:filename', controller='dataset', action='index', dataset_id=None, filename=None)
webapp.add_route( '/display_application/:dataset_id/:app_name/:link_name/:user_id/:app_action/:action_param', controller='dataset', action='display_application', dataset_id=None, user_id=None, app_name = None, link_name = None, app_action = None, action_param = None )
webapp.add_route( '/u/:username/d/:slug', controller='dataset', action='display_by_username_and_slug' )
+12 -11
View File
@@ -267,17 +267,18 @@ class DatasetInterface( BaseController, UsesAnnotations, UsesHistory, UsesHistor
log.exception( "Unable to add composite parent %s to temporary library download archive" % data.file_name)
msg = "Unable to create archive for download, please report this error"
messagetype = 'error'
flist = glob.glob(os.path.join(efp,'*.*')) # glob returns full paths
for fpath in flist:
efp,fname = os.path.split(fpath)
try:
archive.add( fpath,fname )
except IOError:
error = True
log.exception( "Unable to add %s to temporary library download archive" % fname)
msg = "Unable to create archive for download, please report this error"
messagetype = 'error'
continue
for root, dirs, files in os.walk(efp):
for fname in files:
fpath = os.path.join(root,fname)
rpath = os.path.relpath(fpath,efp)
try:
archive.add( fpath,rpath )
except IOError:
error = True
log.exception( "Unable to add %s to temporary library download archive" % rpath)
msg = "Unable to create archive for download, please report this error"
messagetype = 'error'
continue
if not error:
if params.do_action == 'zip':
archive.close()