diff MoinMoin/items/__init__.py @ 292:ebdfe9448e01

make converter api more homogeneous, adapt tests you can give a file-like object (like a revision), a str or unicode now to a input converter (no matter for what mimetype it is). you also need to give the contenttype (at least for the text input converters, they will extract the charset from there and decode appropriately). removed the feed_input_conv methods, we always give the revision and the contenttype now to the converters.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 17 Jul 2011 01:42:53 +0200
parents eea3a94a4061
children 07143bd03aed 748523da8db6 fa1b9282a3ac
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Mon Jul 11 01:10:30 2011 +0200
+++ b/MoinMoin/items/__init__.py	Sun Jul 17 01:42:53 2011 +0200
@@ -218,9 +218,6 @@
         # override this in child classes
         return ''
 
-    def feed_input_conv(self):
-        return self.rev
-
     def internal_representation(self, converters=['smiley']):
         """
         Return the internal representation of a document using a DOM Tree
@@ -249,8 +246,7 @@
 
             # We can process the conversion
             links = Iri(scheme='wiki', authority='', path='/' + self.name)
-            input = self.feed_input_conv()
-            doc = input_conv(input)
+            doc = input_conv(self.rev, self.contenttype)
             # XXX is the following assuming that the top element of the doc tree
             # is a moin_page.page element? if yes, this is the wrong place to do that
             # as not every doc will have that element (e.g. for images, we just get
@@ -1108,9 +1104,6 @@
         """ convert data from storage format to memory format """
         return data.decode(config.charset).replace(u'\r\n', u'\n')
 
-    def feed_input_conv(self):
-        return self.data_storage_to_internal(self.data).split(u'\n')
-
     def _render_data_diff(self, oldrev, newrev):
         from MoinMoin.util.diff_html import diff
         old_text = self.data_storage_to_internal(oldrev.read())
@@ -1216,7 +1209,7 @@
 
         i = Iri(scheme='wiki', authority='', path='/' + self.name)
 
-        doc = input_conv(self.data_storage_to_internal(data).split(u'\n'))
+        doc = input_conv(self.rev, self.contenttype)
         doc.set(moin_page.page_href, unicode(i))
         doc = item_conv(doc)