[moinmoin.py] Port to Moin 1.7

Jan Anlauff <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Hi,
I just upgraded to Moin 1.7 and the MoinMoin plugin broke, the API changed
again. I tried to fix it, the result (bare with my practically
non-existant Python skills ;) is attached. Changes I made to moinmoin.py:

 * 1.7 compatibility
 * improved version checks
 * possible inclusion of config path for Debian farmconfig (this really
   should be configurable, I just could not get it to work otherwise)
 * some comments

It would be great if I could get a copy of the replies as I am not
subscribed to pyblosxom-devel, thanks.

Regards,
 Jan

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
moinmoin.patch (text/x-diff, 2.6 KB)
--- /home/ja/moinmoin.py	2008-07-20 18:30:08.000000000 +0200
+++ moinmoin.py	2008-07-20 18:31:22.000000000 +0200
@@ -52,25 +52,48 @@ SOFTWARE.
 Copyright 2004, 2005 Wari Wahab
 """
 __author__ = 'Wari Wahab <wari at wari dot per dot sg>'
-__version__ = "$Id: moinmoin.py 961 2007-01-02 01:50:50Z ryanbarrett $"
+__version__ = "$Id$"
 PREFORMATTER_ID = 'wiki'
 
-from MoinMoin.parser.wiki import Parser
+import sys
+# If the wikiconfig is in a special location, specify it in config
+# (i.e. Debian wikifarm config / ImportError: No module named wikiconfig)
+#sys.path.append('/etc/moin/')
+
 from MoinMoin.formatter.text_html import Formatter
+
+# MoinMoin >= 1.0
 try:
     from MoinMoin.request import Request
 except:
     pass
+# MoinMoin >= 1.5
 try:
     from MoinMoin.request import RequestCLI
 except:
     pass
+# MoinMoin >= 1.7
+try:
+    from MoinMoin.request.request_cli import Request as RequestCLI
+    request = RequestCLI()
+except:
+    pass
+
+
+# MoinMoin >= 1.7.0 changed this to the latter
+try:
+    from MoinMoin.parser.wiki import Parser
+except:
+    pass
+try:
+    from MoinMoin.parser.text_moin_wiki import Parser
+except:
+    pass
+
 from MoinMoin.Page import Page
 from MoinMoin.user import User
 from cStringIO import StringIO
 from Pyblosxom import tools
-import sys
-
 
 def cb_preformat(args):
     """
@@ -124,7 +147,7 @@ def readfile(filename, request):
 def parse15(story):
     """
     The main workhorse that does nothing but call MoinMoin to do its dirty
-    laundry. This version compatible with MoinMoin 1.5
+    laundry. This function is compatible with MoinMoin 1.5 and higher.
 
     @param story: A text for conversion
     @type story: string
@@ -134,7 +157,7 @@ def parse15(story):
     s = StringIO()
     oldstdout = sys.stdout
     form = None
-    request = RequestCLI()
+    #request = RequestCLI()
     #request.user = User()
     page = Page(request, '')
     page.hilite_re = None
@@ -151,7 +174,7 @@ def parse15(story):
 def parse10(story):
     """
     The main workhorse that does nothing but call MoinMoin to do its dirty
-    laundry. This function compatible with MoinMoin 1.0.
+    laundry. This function is compatible with MoinMoin >= 1.0 and < 1.5
 
     @param story: A text for conversion
     @type story: string
@@ -175,11 +198,13 @@ def parse10(story):
     return result
 
 
+# Use another wrapper for the MoinMoin Parse object for versions >= 1.5
 parse = parse10
 
 try:
     import MoinMoin.version
-    if MoinMoin.version.release[0:3] == '1.5':
-        parse = parse15
+    if MoinMoin.version.release[0:2] == '1.':
+        if int(MoinMoin.version.release[2]) >= 5:
+            parse = parse15
 except:
     pass
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.