Submitted by : wlang at: 2007-05-17T11:21:54-07:00 (10 years ago)
Name :
Category : Severity : Status :
Optional subject :  
Optional comment :

Renaming a wikipage can lead to inconsistency between the outline object and the parents properties.

Example: after renaming the FrontPage of my wiki, i noticed the inconsistency. Looking at the child page AEUmbau (prior to the rename):

instancehome$ ./bin/zopectl debug
>>> app.wikis.BachDocs.AEUmbau.parents
['FrontPage']

Then i renamed "FrontPage" to "BachDocs" via the Rename Button. The page AEUMbau now shows BachDocs as its parent (the outline object seems to be correct).

However, looking at the "parents" attribute from another zeo client (to overcome caching effects) reveals that the parents property still points to FrontPage:

instancehome$ ./bin/zopectl debug
>>> app.wikis.BachDocs.AEUmbau.parents
['FrontPage']

Reason: "parents" is a mutable object (list), thus its change must be signalled to the persistence machinery. The following patch worked for me:

slime:/usr/local/zope/darcs/ZWiki$ darcs diff -u OutlineSupport.py
--- old-ZWiki/OutlineSupport.py 2007-05-17 20:14:19.000000000 +0200
+++ new-ZWiki/OutlineSupport.py 2007-05-17 20:14:19.000000000 +0200
@@ -157,10 +157,13 @@
             if parent and not parent in self.parents:
                 self.ensureParentsPropertyIsList()
                 self.parents.append(parent)
+                self._p_changed = 1

     def removeParent(self,parent):
         self.ensureParentsPropertyIsList()
-        try: self.parents.remove(parent)
+        try:
+            self.parents.remove(parent)
+            self._p_changed = 1
         except ValueError:
             BLATHER("failed to remove %s from %s's parents (%s)" \
                  % (parent,self.getId(),self.parents))

great --simon, Thu, 17 May 2007 16:35:05 -0700 reply

Very interesting, thanks for this Willi.

I wonder how many more of these there are.

parents is a property, we should treat it like one --betabug, Fri, 18 May 2007 00:26:27 -0700 reply

We probably should use the propertymanager API to edit properties, e.g. manage_changeProperties() IIRC

parents is a property, we should treat it like one --wlang, Fri, 18 May 2007 04:06:17 -0700 reply

Good point. But i'm not even sure, that "parents" should be a property in the first place. Parent relations should be defined/changed through the zwiki "reparent" function, and not through the ZMI properties tab (which, i think, would also lead to an inconsistency to the outline cache).

parents is a property, we should treat it like one --betabug, Fri, 18 May 2007 04:55:23 -0700 reply

Having "parents" as a property is an emergency mechanism. If things got really messy at some point you can go in and "fix" pages in the ZMI, then update the outline object. I had to do exactly that a short while ago, because my father managed to "kill" 2 pages on his wiki :-) (of course I fixed his wikipage.pt, so he can't kill any more pages, at least not in that way).

committed in stable & unstable --simon, Thu, 01 May 2008 21:03:34 -0700 reply

Status: open => closed

Thanks!