diff MoinMoin/items/__init__.py @ 1650:07b2146ba96f

Store `itemtype` metadata entry in DummyRev so that newly created items have appropriate itemtype.
author Cheer Xiao <xiaqqaix@gmail.com>
date Wed, 08 Aug 2012 23:03:05 +0800
parents 5dc142ab43d2
children 57e864bb8852 465b22852fae
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Wed Aug 08 22:51:16 2012 +0800
+++ b/MoinMoin/items/__init__.py	Wed Aug 08 23:03:05 2012 +0800
@@ -96,9 +96,9 @@
 
 class DummyRev(dict):
     """ if we have no stored Revision, we use this dummy """
-    def __init__(self, item, contenttype):
+    def __init__(self, item, itemtype, contenttype):
         self.item = item
-        self.meta = {CONTENTTYPE: contenttype}
+        self.meta = {ITEMTYPE: itemtype, CONTENTTYPE: contenttype}
         self.data = StringIO('')
         self.revid = None
 
@@ -165,7 +165,7 @@
         if not item: # except NoSuchItemError:
             logging.debug("No such item: {0!r}".format(name))
             item = DummyItem(name)
-            rev = DummyRev(item, contenttype)
+            rev = DummyRev(item, itemtype, contenttype)
             logging.debug("Item {0!r}, created dummy revision with contenttype {1!r}".format(name, contenttype))
         else:
             logging.debug("Got item: {0!r}".format(name))
@@ -179,7 +179,7 @@
                     # XXX add some message about invalid revision
                 except KeyError: # NoSuchRevisionError:
                     logging.debug("Item {0!r} has no revisions.".format(name))
-                    rev = DummyRev(item, contenttype)
+                    rev = DummyRev(item, itemtype, contenttype)
                     logging.debug("Item {0!r}, created dummy revision with contenttype {1!r}".format(name, contenttype))
             logging.debug("Got item {0!r}, revision: {1!r}".format(name, rev_id))
         contenttype = rev.meta.get(CONTENTTYPE) or contenttype # use contenttype in case our metadata does not provide CONTENTTYPE