diff MoinMoin/items/__init__.py @ 1266:1c66f39aa44f

implement validation for revision metadata storage using flatland Note: currently invalid metadata is not rejected, moin2 will just print out a validation dump if validation fails.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 19 Feb 2012 22:03:56 +0100
parents 3b723046d80e
children 4c4ee1f25e9f
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Sun Feb 19 09:57:03 2012 -0700
+++ b/MoinMoin/items/__init__.py	Sun Feb 19 22:03:56 2012 +0100
@@ -486,18 +486,6 @@
         if comment:
             meta[COMMENT] = unicode(comment)
 
-        if CONTENTTYPE not in meta:
-            # make sure we have CONTENTTYPE
-            meta[CONTENTTYPE] = unicode(contenttype_current or contenttype_guessed or 'application/octet-stream')
-
-        if ADDRESS not in meta:
-            meta[ADDRESS] = u'0.0.0.0' # TODO
-
-        if USERID not in meta and flaskg.user.valid:
-            meta[USERID] = flaskg.user.itemid
-
-        meta[ACTION] = unicode(action)
-
         if not overwrite and REVID in meta:
             # we usually want to create a new revision, thus we must remove the existing REVID
             del meta[REVID]
@@ -511,12 +499,16 @@
                 data = ''
 
         if isinstance(data, unicode):
-            data = data.encode(config.charset)
+            data = data.encode(config.charset) # XXX wrong! if contenttype gives a coding, we MUST use THAT.
 
         if isinstance(data, str):
             data = StringIO(data)
 
-        newrev = storage_item.store_revision(meta, data, overwrite=overwrite)
+        newrev = storage_item.store_revision(meta, data, overwrite=overwrite,
+                                             action=unicode(action),
+                                             contenttype_current=contenttype_current,
+                                             contenttype_guessed=contenttype_guessed,
+                                             )
         item_modified.send(app._get_current_object(), item_name=name)
         return newrev.revid, newrev.meta[SIZE]