changeset 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 c796a6ca82c4
files MoinMoin/items/__init__.py MoinMoin/items/_tests/test_Item.py
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
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]
--- a/MoinMoin/items/_tests/test_Item.py	Sun Aug 12 18:23:24 2012 +0800
+++ b/MoinMoin/items/_tests/test_Item.py	Mon Aug 13 16:42:00 2012 +0800
@@ -18,7 +18,7 @@
 from MoinMoin._tests import become_trusted, update_item
 from MoinMoin.items import Item, NonExistent
 from MoinMoin.items.content import Binary, Text, Image, TransformableBitmapImage, MarkupItem
-from MoinMoin.constants.keys import ITEMTYPE, CONTENTTYPE, ADDRESS, COMMENT, HOSTNAME, USERID, ACTION
+from MoinMoin.constants.keys import ITEMTYPE, CONTENTTYPE, NAME, ADDRESS, COMMENT, HOSTNAME, USERID, ACTION
 
 class TestItem(object):
 
@@ -29,6 +29,7 @@
         assert meta == {
                 ITEMTYPE: u'nonexistent',
                 CONTENTTYPE: u'application/x-nonexistent',
+                NAME: u'DoesNotExist',
                 }
         assert data == ''