diff MoinMoin/items/__init__.py @ 1672:c093039ac8a5

items/__init__.py: DummyRev.__init__: Add default values for itemtype and contenttype, fill in NAME metadata property when appropriate
author Cheer Xiao <xiaqqaix@gmail.com>
date Mon, 13 Aug 2012 16:42:00 +0800
parents d3a1a3e7075f
children 36ae694c4122
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Sun Aug 12 18:23:24 2012 +0800
+++ b/MoinMoin/items/__init__.py	Mon Aug 13 16:42:00 2012 +0800
@@ -98,11 +98,16 @@
 
 class DummyRev(dict):
     """ if we have no stored Revision, we use this dummy """
-    def __init__(self, item, itemtype, contenttype):
+    def __init__(self, item, itemtype=None, contenttype=None):
         self.item = item
-        self.meta = {ITEMTYPE: itemtype, CONTENTTYPE: contenttype}
+        self.meta = {
+            ITEMTYPE: itemtype or u'nonexistent',
+            CONTENTTYPE: contenttype or u'application/x-nonexistent'
+        }
         self.data = StringIO('')
         self.revid = None
+        if self.item:
+            self.meta[NAME] = self.item.name
 
 
 class DummyItem(object):
@@ -155,10 +160,6 @@
         previously created Content instance is assigned to its content
         property.
         """
-        if contenttype is None:
-            contenttype = u'application/x-nonexistent'
-        if itemtype is None:
-            itemtype = u'nonexistent'
         if 1: # try:
             if item is None:
                 item = flaskg.storage[name]