changeset 1042:e666253e7d0d namespaces

pages with multiple names are properly renamed
author Luis Henrique Fagundes <lhfagundes@gmail.com>
date Mon, 31 Oct 2011 03:59:02 -0200
parents 1d3e8fb4a7a8
children c8b219b474d0
files MoinMoin/items/__init__.py MoinMoin/items/_tests/test_Item.py MoinMoin/storage/middleware/indexing.py
diffstat 3 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Mon Oct 31 02:31:59 2011 -0200
+++ b/MoinMoin/items/__init__.py	Mon Oct 31 03:59:02 2011 -0200
@@ -20,6 +20,7 @@
 import zipfile
 import tempfile
 import itertools
+import types
 from StringIO import StringIO
 from array import array
 
@@ -469,9 +470,19 @@
         if name is None:
             name = self.name
         oldname = meta.get(NAME)
-        if oldname and oldname != name:
-            meta[NAME_OLD] = oldname
-        meta[NAME] = name
+        if oldname:
+            if type(oldname) is not types.ListType:
+                oldname = [oldname]
+            if name not in oldname: #this is a rename
+                meta[NAME_OLD] = oldname[:]
+                try:
+                    oldname.remove(self.name)
+                except ValueError:
+                    pass
+                oldname.append(name)
+                meta[NAME] = oldname
+        else:
+            meta[NAME] = [name]
 
         if comment:
             meta[COMMENT] = unicode(comment)
--- a/MoinMoin/items/_tests/test_Item.py	Mon Oct 31 02:31:59 2011 -0200
+++ b/MoinMoin/items/_tests/test_Item.py	Mon Oct 31 03:59:02 2011 -0200
@@ -221,7 +221,7 @@
         # item at new name and its contents after renaming
         item = Item.create(new_name)
         assert item.name == u'Test_new_Item'
-        assert item.meta['name_old'] == u'Test_Item'
+        assert item.meta['name_old'] == [u'Test_Item']
         assert item.meta['comment'] == u'renamed'
         assert item.data == u'test_data'
 
--- a/MoinMoin/storage/middleware/indexing.py	Mon Oct 31 02:31:59 2011 -0200
+++ b/MoinMoin/storage/middleware/indexing.py	Mon Oct 31 03:59:02 2011 -0200
@@ -133,7 +133,7 @@
             class PseudoItem(object):
                 def __init__(self, name):
                     self.name = name
-            self.item = PseudoItem(meta.get(NAME))
+            self.item = PseudoItem(item_name)
         def read(self, *args, **kw):
             return self.data.read(*args, **kw)
         def seek(self, *args, **kw):