[hg] galaxy 3689: Move setting categories to the Tool class in t...
details: http://www.bx.psu.edu/hg/galaxy/rev/a66d849924d2 changeset: 3689:a66d849924d2 user: Nate Coraor <nate@bx.psu.edu> date: Fri Apr 23 16:24:49 2010 -0400 description: Move setting categories to the Tool class in the model diffstat: lib/galaxy/webapps/community/controllers/tool_browser.py | 17 +--------------- lib/galaxy/webapps/community/model/__init__.py | 9 ++++++++ 2 files changed, 10 insertions(+), 16 deletions(-) diffs (50 lines): diff -r 87cee993fa2d -r a66d849924d2 lib/galaxy/webapps/community/controllers/tool_browser.py --- a/lib/galaxy/webapps/community/controllers/tool_browser.py Fri Apr 23 16:11:55 2010 -0400 +++ b/lib/galaxy/webapps/community/controllers/tool_browser.py Fri Apr 23 16:24:49 2010 -0400 @@ -117,7 +117,7 @@ elif params.save_button: tool.user_description = util.restore_text( params.description ) categories = [] - set_tool_category_associations( trans, tool, util.listify( params.category ) ) + tool.set_categories( trans, util.listify( params.category ) ) trans.sa_session.add( tool ) trans.sa_session.flush() return trans.response.send_redirect( web.url_for( controller='tool_browser', @@ -131,18 +131,3 @@ categories=categories, message=message, status=status ) - -## ---- Utility methods ------------------------------------------------------- - -# It may make sense to create something like the security controller to do -# this, but seems unnecessary for this single operation - -def set_tool_category_associations( trans, tool, categories, delete_existing_assocs=True ): - if delete_existing_assocs: - for a in tool.categories: - trans.sa_session.delete( a ) - trans.sa_session.flush() - for category in categories: - if not isinstance( category, trans.model.Category ): - category = trans.sa_session.query( trans.model.Category ).get( int( category ) ) - tool.categories.append( trans.model.ToolCategoryAssociation( tool, category ) ) diff -r 87cee993fa2d -r a66d849924d2 lib/galaxy/webapps/community/model/__init__.py --- a/lib/galaxy/webapps/community/model/__init__.py Fri Apr 23 16:11:55 2010 -0400 +++ b/lib/galaxy/webapps/community/model/__init__.py Fri Apr 23 16:24:49 2010 -0400 @@ -123,6 +123,15 @@ self.description = datatype_bunch.description self.version = datatype_bunch.version self.user_id = datatype_bunch.user.id + def set_categories( self, trans, categories, delete_existing_assocs=True ): + if delete_existing_assocs: + for a in self.categories: + trans.sa_session.delete( a ) + trans.sa_session.flush() + for category in categories: + if not isinstance( category, Category ): + category = trans.sa_session.query( Category ).get( int( category ) ) + self.categories.append( ToolCategoryAssociation( self, category ) ) class Tag ( object ): def __init__( self, id=None, type=None, parent_id=None, name=None ):
participants (1)
-
Nate Coraor