diff --git a/config/galaxy.ini.sample b/config/galaxy.ini.sample index dbc13b0ca32..d0d9438808d 100644 --- a/config/galaxy.ini.sample +++ b/config/galaxy.ini.sample @@ -1013,13 +1013,23 @@ use_interactive = True # database for authentication) and set the following two options. # This should point to a directory containing subdirectories matching users' -# email addresses, where Galaxy will look for files. +# identifer (defaults to e-mail), where Galaxy will look for files. #ftp_upload_dir = None # This should be the hostname of your FTP server, which will be provided to # users in the help text. #ftp_upload_site = None +# User attribute to use as subdirectory in calculating default ftp_upload_dir +# pattern. By default this will be email so a user's FTP upload directory will be +# ${ftp_upload_dir}/${user.email}. Can set this to other attributes such as id or +# username though. +#ftp_upload_dir_identifier = email + +# Python string tempalte used to determine an FTP upload directory for a +# particular user. +#ftp_upload_dir_template = ${ftp_upload_dir}/${ftp_upload_dir_identifier} + # Enable enforcement of quotas. Quotas can be set from the Admin interface. #enable_quotas = False diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index bfae71b72db..a85efd03f2b 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -292,6 +292,7 @@ class Configuration( object ): self.whoosh_index_dir = resolve_path( kwargs.get( "whoosh_index_dir", "database/whoosh_indexes" ), self.root ) self.ftp_upload_dir = kwargs.get( 'ftp_upload_dir', None ) self.ftp_upload_dir_identifier = kwargs.get( 'ftp_upload_dir_identifier', 'email' ) # attribute on user - email, username, id, etc... + self.ftp_upload_dir_template = kwargs.get( 'ftp_upload_dir_template', '${ftp_upload_dir}%s${ftp_upload_dir_identifier}' % os.path.sep ) self.ftp_upload_site = kwargs.get( 'ftp_upload_site', None ) self.allow_library_path_paste = kwargs.get( 'allow_library_path_paste', False ) self.disable_library_comptypes = kwargs.get( 'disable_library_comptypes', '' ).lower().split( ',' ) diff --git a/lib/galaxy/managers/context.py b/lib/galaxy/managers/context.py index 822dbee4475..9dde7a241a5 100644 --- a/lib/galaxy/managers/context.py +++ b/lib/galaxy/managers/context.py @@ -2,8 +2,8 @@ Mixins for transaction-like objects. """ -import os from json import dumps +import string from galaxy.util import bunch @@ -139,12 +139,17 @@ class ProvidesUserContext( object ): @property def user_ftp_dir( self ): - identifier = self.app.config.ftp_upload_dir_identifier base_dir = self.app.config.ftp_upload_dir if base_dir is None: return None else: - return os.path.join( base_dir, getattr( self.user, identifier ) ) + identifier = self.app.config.ftp_upload_dir_identifier + template = self.app.config.ftp_upload_dir_template + path = string.Template(template).safe_substitute(dict( + ftp_upload_dir=base_dir, + ftp_upload_dir_identifier=identifier, + )) + return path class ProvidesHistoryContext( object ):