3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/6a10ee8260f5/ changeset: 6a10ee8260f5 user: jgoecks date: 2012-11-11 02:31:03 summary: Use a single generic method for asynchronously setting an item's slug. affected #: 5 files diff -r 5fdb5348d968f5bb38aedba23e26bdb9032a0c0b -r 6a10ee8260f5682bca6637ba855263426bee57de lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -1487,16 +1487,19 @@ user.username = username trans.sa_session.flush return self.sharing( trans, id, **kwargs ) + + @web.expose + @web.require_login( "modify Galaxy items" ) + def set_slug_async( self, trans, id, new_slug ): + item = self.get_item( trans, id ) + if item: + item.slug = new_slug + trans.sa_session.flush() + return item.slug # -- Abstract methods. -- @web.expose - @web.require_login( "modify Galaxy items" ) - def set_slug_async( self, trans, id, new_slug ): - """ Set item slug asynchronously. """ - raise "Unimplemented Method" - - @web.expose @web.require_login( "share Galaxy items" ) def sharing( self, trans, id, **kwargs ): """ Handle item sharing. """ diff -r 5fdb5348d968f5bb38aedba23e26bdb9032a0c0b -r 6a10ee8260f5682bca6637ba855263426bee57de lib/galaxy/webapps/galaxy/controllers/history.py --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -725,15 +725,6 @@ return @web.expose - @web.require_login( "modify Galaxy items" ) - def set_slug_async( self, trans, id, new_slug ): - history = self.get_history( trans, id ) - if history: - history.slug = new_slug - trans.sa_session.flush() - return history.slug - - @web.expose def get_item_content_async( self, trans, id ): """ Returns item content in HTML format. """ diff -r 5fdb5348d968f5bb38aedba23e26bdb9032a0c0b -r 6a10ee8260f5682bca6637ba855263426bee57de lib/galaxy/webapps/galaxy/controllers/page.py --- a/lib/galaxy/webapps/galaxy/controllers/page.py +++ b/lib/galaxy/webapps/galaxy/controllers/page.py @@ -621,15 +621,6 @@ return @web.expose - @web.require_login( "modify Galaxy items" ) - def set_slug_async( self, trans, id, new_slug ): - page = self.get_page( trans, id ) - if page: - page.slug = new_slug - trans.sa_session.flush() - return page.slug - - @web.expose @web.require_login( "rate items" ) @web.json def rate_async( self, trans, id, rating ): diff -r 5fdb5348d968f5bb38aedba23e26bdb9032a0c0b -r 6a10ee8260f5682bca6637ba855263426bee57de lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -366,17 +366,7 @@ # Display the management page trans.set_message( 'Copy created with name "%s"' % cloned_visualization.title ) return self.list( trans ) - - @web.expose - @web.require_login( "modify Galaxy visualizations" ) - def set_slug_async( self, trans, id, new_slug ): - """ Set item slug asynchronously. """ - visualization = self.get_visualization( trans, id ) - if visualization: - visualization.slug = new_slug - trans.sa_session.flush() - return visualization.slug - + @web.expose @web.require_login( "use Galaxy visualizations" ) def set_accessible_async( self, trans, id=None, accessible=False ): diff -r 5fdb5348d968f5bb38aedba23e26bdb9032a0c0b -r 6a10ee8260f5682bca6637ba855263426bee57de lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -468,15 +468,6 @@ return @web.expose - @web.require_login( "modify Galaxy items" ) - def set_slug_async( self, trans, id, new_slug ): - stored = self.get_stored_workflow( trans, id ) - if stored: - stored.slug = new_slug - trans.sa_session.flush() - return stored.slug - - @web.expose def get_embed_html_async( self, trans, id ): """ Returns HTML for embedding a workflow in a page. """ https://bitbucket.org/galaxy/galaxy-central/changeset/5c1420204d84/ changeset: 5c1420204d84 user: jgoecks date: 2012-11-11 04:50:33 summary: Ignore shed_tool_data_table_conf.xml in repository. affected #: 1 file diff -r 6a10ee8260f5682bca6637ba855263426bee57de -r 5c1420204d84e980ee5c2f3828d188cb0037505a .hgignore --- a/.hgignore +++ b/.hgignore @@ -28,6 +28,7 @@ reports_wsgi.ini community_wsgi.ini +# Config files. datatypes_conf.xml tool_conf.xml external_service_types_conf.xml @@ -37,6 +38,7 @@ tool_sheds_conf.xml integrated_tool_panel.xml openid_conf.xml +shed_tool_data_table_conf.xml static/welcome.html.* static/welcome.html https://bitbucket.org/galaxy/galaxy-central/changeset/dd63b34f8139/ changeset: dd63b34f8139 user: jgoecks date: 2012-11-11 04:53:35 summary: Ensure that slugs cannot be duplicated for active, importable items. affected #: 1 file diff -r 5c1420204d84e980ee5c2f3828d188cb0037505a -r dd63b34f813972b00f7bf492aec1e74ef9bd5f59 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -1493,9 +1493,57 @@ def set_slug_async( self, trans, id, new_slug ): item = self.get_item( trans, id ) if item: - item.slug = new_slug - trans.sa_session.flush() - return item.slug + # Only update slug if slug is not already in use. + if trans.sa_session.query( item.__class__ ).filter_by( user=item.user, slug=new_slug, importable=True ).count() == 0: + item.slug = new_slug + trans.sa_session.flush() + + return item.slug + + def _make_item_accessible( self, sa_session, item ): + """ Makes item accessible--viewable and importable--and sets item's slug. + Does not flush/commit changes, however. Item must have name, user, + importable, and slug attributes. """ + item.importable = True + self.create_item_slug( sa_session, item ) + + def create_item_slug( self, sa_session, item ): + """ Create/set item slug. Slug is unique among user's importable items + for item's class. Returns true if item's slug was set/changed; false + otherwise. + """ + cur_slug = item.slug + + # Setup slug base. + if cur_slug is None or cur_slug == "": + # Item can have either a name or a title. + if hasattr( item, 'name' ): + item_name = item.name + elif hasattr( item, 'title' ): + item_name = item.title + # Replace whitespace with '-' + slug_base = re.sub( "\s+", "-", item_name.lower() ) + # Remove all non-alphanumeric characters. + slug_base = re.sub( "[^a-zA-Z0-9\-]", "", slug_base ) + # Remove trailing '-'. + if slug_base.endswith('-'): + slug_base = slug_base[:-1] + else: + slug_base = cur_slug + + # Using slug base, find a slug that is not taken. If slug is taken, + # add integer to end. + new_slug = slug_base + count = 1 + while sa_session.query( item.__class__ ).filter_by( user=item.user, slug=new_slug, importable=True ).count() != 0: + # Slug taken; choose a new slug based on count. This approach can + # handle numerous items with the same name gracefully. + new_slug = '%s-%i' % ( slug_base, count ) + count += 1 + + # Set slug and return. + item.slug = new_slug + return item.slug == cur_slug # -- Abstract methods. -- @@ -1527,39 +1575,6 @@ def get_item_content_async( self, trans, id ): """ Returns item content in HTML format. """ raise "Unimplemented Method" - - # -- Helper methods. -- - - def _make_item_accessible( self, sa_session, item ): - """ Makes item accessible--viewable and importable--and sets item's slug. Does not flush/commit changes, however. Item must have name, user, importable, and slug attributes. """ - item.importable = True - self.create_item_slug( sa_session, item ) - - def create_item_slug( self, sa_session, item ): - """ Create item slug. Slug is unique among user's importable items for item's class. Returns true if item's slug was set; false otherwise. """ - if item.slug is None or item.slug == "": - # Item can have either a name or a title. - if hasattr( item, 'name' ): - item_name = item.name - elif hasattr( item, 'title' ): - item_name = item.title - # Replace whitespace with '-' - slug_base = re.sub( "\s+", "-", item_name.lower() ) - # Remove all non-alphanumeric characters. - slug_base = re.sub( "[^a-zA-Z0-9\-]", "", slug_base ) - # Remove trailing '-'. - if slug_base.endswith('-'): - slug_base = slug_base[:-1] - # Make sure that slug is not taken; if it is, add a number to it. - slug = slug_base - count = 1 - while sa_session.query( item.__class__ ).filter_by( user=item.user, slug=slug, importable=True ).count() != 0: - # Slug taken; choose a new slug based on count. This approach can handle numerous items with the same name gracefully. - slug = '%s-%i' % ( slug_base, count ) - count += 1 - item.slug = slug - return True - return False def get_item( self, trans, id ): """ Return item based on id. """ 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.