changeset 1935:2589c6bc54d7 namespaces

fix item rename/delete for NAME meta being a list of names
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 03 Feb 2013 13:39:05 +0100
parents ee43744a3ac8
children 7162f665f752
files MoinMoin/items/__init__.py
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Sun Feb 03 05:07:08 2013 +0100
+++ b/MoinMoin/items/__init__.py	Sun Feb 03 13:39:05 2013 +0100
@@ -315,13 +315,19 @@
 
     def _rename(self, name, comment, action, delete=False):
         self._save(self.meta, self.content.data, name=name, action=action, comment=comment, delete=delete)
-        old_prefixlen = len(self.subitems_prefix)
-        new_prefix = name + '/'  # XXX BROKEN for name==None
+        old_prefix = self.subitems_prefix
+        old_prefixlen = len(old_prefix)
+        if not delete:
+            new_prefix = name + '/'
         for child in self.get_subitem_revs():
-            child_oldname = child.meta[NAME]  # XXX BROKEN - this is a list of names now
-            child_newname = new_prefix + child_oldname[old_prefixlen:]
-            item = Item.create(child_oldname)
-            item._save(item.meta, item.content.data, name=child_newname, action=action, comment=comment, delete=delete)
+            for child_oldname in child.meta[NAME]:
+                if child_oldname.startswith(old_prefix):
+                    if delete:
+                        child_newname = None
+                    else:  # rename
+                        child_newname = new_prefix + child_oldname[old_prefixlen:]
+                    item = Item.create(child_oldname)
+                    item._save(item.meta, item.content.data, name=child_newname, action=action, comment=comment, delete=delete)
 
     def rename(self, name, comment=u''):
         """