1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6638dbca87d3/ Changeset: 6638dbca87d3 User: carlfeberhard Date: 2013-04-26 21:36:33 Summary: Configuration API: include and standardize error handling, complete documentation Affected #: 1 file diff -r a0877019caa1e1f6b4407d92eaa7c44f654d27df -r 6638dbca87d3c7dfc4e5b0522eb4a17f124b5040 lib/galaxy/webapps/galaxy/api/configuration.py --- a/lib/galaxy/webapps/galaxy/api/configuration.py +++ b/lib/galaxy/webapps/galaxy/api/configuration.py @@ -1,5 +1,6 @@ """ -API operations allowing clients to determine Galaxy instance's capabilities. +API operations allowing clients to determine Galaxy instance's capabilities +and configuration settings. """ from galaxy import web @@ -9,6 +10,7 @@ log = logging.getLogger( __name__ ) class ConfigurationController( BaseAPIController ): + # config attributes viewable by non-admin users EXPOSED_USER_OPTIONS = [ 'enable_unique_workflow_defaults', 'ftp_upload_site', @@ -19,6 +21,7 @@ 'terms_url', 'allow_user_dataset_purge', ] + # config attributes viewable by admin users EXPOSED_ADMIN_OPTIONS = [ 'library_import_dir', 'user_library_import_dir', @@ -30,12 +33,28 @@ @web.expose_api def index( self, trans, **kwd ): """ + GET /api/configuration + Return an object containing exposable configuration settings. + + Note: a more complete list is returned if the user is an admin. """ - config = trans.app.config - options = self._get_options( config, self.EXPOSED_USER_OPTIONS ) - if trans.user_is_admin(): - options.update( self._get_options( config, self.EXPOSED_ADMIN_OPTIONS ) ) - return options + try: + config = trans.app.config + options = self._get_options( config, self.EXPOSED_USER_OPTIONS ) + if trans.user_is_admin(): + options.update( self._get_options( config, self.EXPOSED_ADMIN_OPTIONS ) ) + return options + + except Exception, exception: + log.error( 'could not get configuration: %s', str( exception ), exc_info=True ) + trans.response.status = 500 + return { 'error': str( exception ) } def _get_options( self, config, keys ): + """ + Build and return a subset of the config dictionary restricted to the + list `keys`. + + The attribute value will default to None if not available. + """ return dict( [ (key, getattr( config, key, None ) ) for key in keys ] ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.