[Checkins] SVN: Products.PluginRegistry/trunk/Products/PluginRegistry/ Add patch for https://bugs.launchpad.net/bugs/164717

Wichert Akkerman wichert at wiggy.net
Sat Nov 24 09:11:08 EST 2007


Log message for revision 81977:
  Add patch for https://bugs.launchpad.net/bugs/164717

Changed:
  U   Products.PluginRegistry/trunk/Products/PluginRegistry/CHANGES.txt
  U   Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py
  U   Products.PluginRegistry/trunk/Products/PluginRegistry/tests/test_PluginRegistry.py
  U   Products.PluginRegistry/trunk/Products/PluginRegistry/version.txt

-=-
Modified: Products.PluginRegistry/trunk/Products/PluginRegistry/CHANGES.txt
===================================================================
--- Products.PluginRegistry/trunk/Products/PluginRegistry/CHANGES.txt	2007-11-24 13:33:19 UTC (rev 81976)
+++ Products.PluginRegistry/trunk/Products/PluginRegistry/CHANGES.txt	2007-11-24 14:11:08 UTC (rev 81977)
@@ -1,5 +1,10 @@
 PluginRegistry Product Changelog
 
+  PluginRegistry 1.2 (unreleased)
+  
+    - Fix bad behaviour when moving the top plugin up.
+      (https://bugs.launchpad.net/bugs/164717)
+
   PluginRegistry 1.1.2 (2007/04/24)
 
     - Drop previously-activated plugins from the list returned from

Modified: Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py
===================================================================
--- Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py	2007-11-24 13:33:19 UTC (rev 81976)
+++ Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py	2007-11-24 14:11:08 UTC (rev 81977)
@@ -202,8 +202,9 @@
                 raise IndexError, i1
 
             i2 = i1 - 1
-            if i2 < 0:      # wrap to bottom
-                i2 = len( ids ) - 1
+            if i2 < 0:
+                # i1 is already on top
+                continue
 
             ids[ i2 ], ids[ i1 ] = ids[ i1 ], ids[ i2 ]
 
@@ -227,8 +228,9 @@
                 raise IndexError, i1
 
             i2 = i1 + 1
-            if i2 == len( ids ):      # wrap to top
-                i2 = 0
+            if i2 == len( ids ):
+                # i1 is already on the bottom
+                continue
 
             ids[ i2 ], ids[ i1 ] = ids[ i1 ], ids[ i2 ]
 

Modified: Products.PluginRegistry/trunk/Products/PluginRegistry/tests/test_PluginRegistry.py
===================================================================
--- Products.PluginRegistry/trunk/Products/PluginRegistry/tests/test_PluginRegistry.py	2007-11-24 13:33:19 UTC (rev 81976)
+++ Products.PluginRegistry/trunk/Products/PluginRegistry/tests/test_PluginRegistry.py	2007-11-24 14:11:08 UTC (rev 81977)
@@ -208,6 +208,19 @@
         self.assertEqual( idlist[1], 'baz_plugin' )
         self.assertEqual( idlist[2], 'foo_plugin' )
 
+        # Moving the top plugin up should not change anything.
+        preg.movePluginsUp( IFoo, ( 'bar_plugin', ) )
+        idlist = preg.listPluginIds( IFoo )
+        self.assertEqual(idlist, 
+                         ('bar_plugin', 'baz_plugin', 'foo_plugin'))
+
+        # Moving the top plugin and another one could change something.
+        preg.movePluginsUp( IFoo, ( 'bar_plugin', 'foo_plugin' ) )
+        idlist = preg.listPluginIds( IFoo )
+        self.assertEqual(idlist, 
+                         ('bar_plugin', 'foo_plugin', 'baz_plugin'))
+
+
     def test_movePluginsDown( self ):
 
         parent = DummyFolder()
@@ -241,6 +254,18 @@
         self.assertEqual( idlist[1], 'foo_plugin' )
         self.assertEqual( idlist[2], 'bar_plugin' )
 
+        # Moving the lowest plugin down should not change anything.
+        preg.movePluginsDown( IFoo, ( 'bar_plugin', ) )
+        idlist = preg.listPluginIds( IFoo )
+        self.assertEqual(idlist, 
+                         ('baz_plugin', 'foo_plugin', 'bar_plugin'))
+
+        # Moving the lowest plugin and another one could change something.
+        preg.movePluginsDown( IFoo, ( 'bar_plugin', 'baz_plugin' ) )
+        idlist = preg.listPluginIds( IFoo )
+        self.assertEqual(idlist, 
+                         ('foo_plugin', 'baz_plugin', 'bar_plugin'))
+
     def test_getAllPlugins( self ):
 
         parent = DummyFolder()

Modified: Products.PluginRegistry/trunk/Products/PluginRegistry/version.txt
===================================================================
--- Products.PluginRegistry/trunk/Products/PluginRegistry/version.txt	2007-11-24 13:33:19 UTC (rev 81976)
+++ Products.PluginRegistry/trunk/Products/PluginRegistry/version.txt	2007-11-24 14:11:08 UTC (rev 81977)
@@ -1 +1 @@
-1.1.2
+1.2dev



More information about the Checkins mailing list