diff MoinMoin/PageGraphicalEditor.py @ 1908:8bd4b581cc60

make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Mar 2007 01:34:47 +0100
parents b07b4c102d3d
children be140a589f11
line wrap: on
line diff
--- a/MoinMoin/PageGraphicalEditor.py	Sat Mar 24 22:25:00 2007 +0100
+++ b/MoinMoin/PageGraphicalEditor.py	Sun Mar 25 01:34:47 2007 +0100
@@ -13,7 +13,7 @@
 from MoinMoin.widget import html
 from MoinMoin.widget.dialog import Status
 from MoinMoin.util import web
-from MoinMoin.parser.text_moin_wiki import Parser
+from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
 
 def execute(pagename, request):
     if not request.user.may.write(pagename):
@@ -28,7 +28,7 @@
 
     def word_rule(self):
         regex = re.compile(r"\(\?<![^)]*?\)")
-        word_rule = regex.sub("", Parser.word_rule)
+        word_rule = regex.sub("", WikiParser.word_rule)
         return repr(word_rule)[1:]
 
     def sendEditor(self, **kw):
@@ -233,6 +233,10 @@
         # Send revision of the page our edit is based on
         request.write('<input type="hidden" name="rev" value="%d">' % (rev,))
 
+        # Add src format (e.g. 'wiki') into a hidden form field, so that
+        # we can load the correct converter after POSTing.
+        request.write('<input type="hidden" name="format" value="%s">' % self.pi['format'])
+        
         # Create and send a ticket, so we can check the POST
         request.write('<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(request))
 
@@ -318,7 +322,7 @@
         from MoinMoin.formatter.text_gedit import Formatter
         self.formatter = Formatter(request)
         self.formatter.page = self
-        output = request.redirectedOutput(self.send_page_content, request, Parser, raw_body, do_cache=False)
+        output = request.redirectedOutput(self.send_page_content, request, raw_body, format=self.pi['format'], do_cache=False)
         output = repr(output)
         if output[0] == 'u':
             output = output[1:]