diff MoinMoin/items/__init__.py @ 157:4d706850ec7c

before_revision_commit: deal with file-like data also
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 21 Mar 2011 19:46:42 +0100
parents e90768ec963c
children 7926fa38e797
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Mon Mar 21 00:58:19 2011 +0100
+++ b/MoinMoin/items/__init__.py	Mon Mar 21 19:46:42 2011 +0100
@@ -1055,6 +1055,14 @@
         """
         super(MarkupItem, self).before_revision_commit(newrev, data)
 
+        if hasattr(data, "read"):
+            data.seek(0)
+            data = data.read()
+        elif isinstance(data, str):
+            pass
+        else:
+            raise StorageError("unsupported content object: %r" % data)
+
         from MoinMoin.converter import default_registry as reg
         from MoinMoin.util.iri import Iri
         from MoinMoin.util.mime import Type, type_moin_document