1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/42648ced82d2/ Changeset: 42648ced82d2 User: carlfeberhard Date: 2015-02-09 16:49:49+00:00 Summary: API, configuration: doc and clean up Affected #: 1 file diff -r 56d2d104edc249ec56eeefaaa6b25349bfcccd8d -r 42648ced82d2ea0f47279fda0a244c6e8b655db3 lib/galaxy/webapps/galaxy/api/configuration.py --- a/lib/galaxy/webapps/galaxy/api/configuration.py +++ b/lib/galaxy/webapps/galaxy/api/configuration.py @@ -31,18 +31,25 @@ serialization_params = self._parse_serialization_params( kwd, 'all' ) return self.get_config_dict( trans, is_admin, **serialization_params ) - def get_config_dict( self, trans, return_admin=False, **kwargs ): + def get_config_dict( self, trans, return_admin=False, view=None, keys=None, default_view='all' ): + """ + Return a dictionary with (a subset of) current Galaxy settings. + + If `return_admin` also include a subset of more sensitive keys. + Pass in `view` (String) and comma seperated list of keys to control which + configuration settings are returned. + """ serializer = self.config_serializer if return_admin: #TODO: this should probably just be under a different route: 'admin/configuration' serializer = self.admin_config_serializer - if 'default_view' not in kwargs: - kwargs[ 'default_view' ] = serializer.default_view - serialized = serializer.serialize_to_view( trans, self.app.config, **kwargs ) + serialized = serializer.serialize_to_view( trans, self.app.config, + view=view, keys=keys, default_view=default_view ) return serialized +#TODO: for lack of a manager file for the config. May well be better in config.py? Circ imports? class ConfigSerializer( base.ModelSerializer ): def __init__( self, app ): @@ -54,42 +61,42 @@ def default_serializer( self, trans, config, key ): return config.get( key, None ) - def _defaults_to( self, default ): - return lambda t, i, k: i.get( k, default ) + def add_serializers( self ): + def _defaults_to( default ): + return lambda t, i, k: i.get( k, default ) - def add_serializers( self ): self.serializers = { #TODO: this is available from user data, remove 'is_admin_user' : lambda *a: False, - 'brand' : lambda t, i, k: i.get( k, "" ), + 'brand' : _defaults_to( '' ), #TODO: this doesn't seem right - 'logo_url' : lambda t, i, k: self.url_for( i.get( k, '/') ), - 'terms_url' : lambda t, i, k: i.get( k, "" ), + 'logo_url' : lambda t, i, k: self.url_for( i.get( k, '/' ) ), + 'terms_url' : _defaults_to( '' ), #TODO: don't hardcode here - hardcode defaults once in config.py - 'wiki_url' : self._defaults_to( "http://galaxyproject.org/" ), - 'search_url' : self._defaults_to( "http://galaxyproject.org/search/usegalaxy/" ), - 'mailing_lists' : self._defaults_to( "http://wiki.galaxyproject.org/MailingLists" ), - 'screencasts_url' : self._defaults_to( "http://vimeo.com/galaxyproject" ), - 'citation_url' : self._defaults_to( "http://wiki.galaxyproject.org/CitingGalaxy" ), - 'support_url' : self._defaults_to( "http://wiki.galaxyproject.org/Support" ), - 'lims_doc_url' : self._defaults_to( "http://main.g2.bx.psu.edu/u/rkchak/p/sts" ), - 'biostar_url' : lambda t, i, k: i.biostar_url, + 'wiki_url' : _defaults_to( "http://galaxyproject.org/" ), + 'search_url' : _defaults_to( "http://galaxyproject.org/search/usegalaxy/" ), + 'mailing_lists' : _defaults_to( "http://wiki.galaxyproject.org/MailingLists" ), + 'screencasts_url' : _defaults_to( "http://vimeo.com/galaxyproject" ), + 'citation_url' : _defaults_to( "http://wiki.galaxyproject.org/CitingGalaxy" ), + 'support_url' : _defaults_to( "http://wiki.galaxyproject.org/Support" ), + 'lims_doc_url' : _defaults_to( "http://main.g2.bx.psu.edu/u/rkchak/p/sts" ), + 'biostar_url' : _defaults_to( '' ), 'biostar_url_redirect' : lambda *a: self.url_for( controller='biostar', action='biostar_redirect', - qualified=True ), + qualified=True ), - 'allow_user_creation' : lambda t, i, k: i.allow_user_creation, - 'use_remote_user' : lambda t, i, k: i.use_remote_user, - 'remote_user_logout_href' : lambda t, i, k: i.remote_user_logout_href, - 'enable_cloud_launch' : self._defaults_to( False ), - 'datatypes_disable_auto' : self._defaults_to( False ), - 'allow_user_dataset_purge' : self._defaults_to( False ), - 'enable_unique_workflow_defaults' : self._defaults_to( False ), + 'allow_user_creation' : _defaults_to( False ), + 'use_remote_user' : _defaults_to( None ), + 'remote_user_logout_href' : _defaults_to( '' ), + 'enable_cloud_launch' : _defaults_to( False ), + 'datatypes_disable_auto' : _defaults_to( False ), + 'allow_user_dataset_purge' : _defaults_to( False ), + 'enable_unique_workflow_defaults' : _defaults_to( False ), - 'nginx_upload_path' : self._defaults_to( self.url_for( controller='api', action='tools' ) ), - 'ftp_upload_dir' : self._defaults_to( None ), - 'ftp_upload_site' : self._defaults_to( None ), + 'nginx_upload_path' : _defaults_to( self.url_for( controller='api', action='tools' ) ), + 'ftp_upload_dir' : _defaults_to( None ), + 'ftp_upload_site' : _defaults_to( None ), } @@ -98,14 +105,16 @@ def add_serializers( self ): super( AdminConfigSerializer, self ).add_serializers() + def _defaults_to( default ): + return lambda t, i, k: i.get( k, default ) self.serializers.update({ #TODO: this is available from user data, remove 'is_admin_user' : lambda *a: True, - 'library_import_dir' : self._defaults_to( None ), - 'user_library_import_dir' : self._defaults_to( None ), - 'allow_library_path_paste' : self._defaults_to( None ), - 'allow_user_creation' : self._defaults_to( False ), - 'allow_user_deletion' : self._defaults_to( False ), + 'library_import_dir' : _defaults_to( None ), + 'user_library_import_dir' : _defaults_to( None ), + 'allow_library_path_paste' : _defaults_to( False ), + 'allow_user_creation' : _defaults_to( False ), + 'allow_user_deletion' : _defaults_to( False ), }) 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.