Need to host MoinMoin under IIS? No problem.

This is a free, easy to install IIS extenstion, written in Python. With it MoinMoin should run as fast as with FastCGI or mod_python, and its configuration is much easier than those.

Current version: 3.

Prerequisites


Installation


  1. Install MoinMoin as usual, using its intallation instructions. I recommend you check your installation using .cgi first, to be sure it's ok with it. Be sure you've created /wiki virtual folder. Check HelpOnInstalling/InternetInformationServer for details.

  2. Download MoinIIS.py file from attachments: MoinIIS.py and put it in some directory. Make sure it has no spaces in the path name, it appears that MoinMoin 1.3.5 has some bug for that case. Copy your wikiconfig.py into the same directory and edit it if need.

    • /!\ It happened that the original file was somehow deleted off this page, so I put newer version; it should work slightly better with attachment files named with national characters. Avoid it, BTW, found some bad bugs in cgi module and, that's wose, in IE file download.

  3. Configure MoinIIS.py; there are 2 parameters in the beginning of the file:
    • The virtual path to your MoinMoin wiki instance. Feel free to change. Default is /themoin.

    • If you installed MoinMoin to the specific, not default, location, add path to it to the second parameter (and uncomment it, of course).

  4. Install the ISAPI extension:
    • From the command prompt, go to the directory mentioned above and run:

MoinIIS.py install

If you have virtual server, use instead

MoinIIS.py --server=my.server.net install

That's all. Now try to reach http://your.server.net/themoin.

Remove

Just the same, but use

MoinIIS.py remove

If you have virtual server, use instead

MoinIIS.py --server=my.server.net remove

Settings

You can change the settings in the wikiconfig.py and MoinIIS.py anytime, there is automatic realoading and caching.

Known bugs

Contacts:

Sergey Chernov, <sergeych AT tancher DOT com>. Feel free to email me.

Comments

Please put your ideas, impressions and any other comments there. Put there what you want to see in the next version and I'll try to implement it.


c:\MoinISAPI>python MoinIIS.py install
ItemNotFound: WebServer IIS://LocalHost/W3SVC/1: The system cannot find the path specified.

Sergey Chernov: Well, looks like you have to specify server name, one that you see in the IIS management console; try it like this:

MoinIIS.py --server <server-name> install

Usually one needs it when there is more than one server on the IIS; maybe the port number is a part of the server name?

WSL3 (2006-02-20): I tried a number of ways of specifying the server name, with and without the port number -- no luck. I'm pretty sure that it's a security issue with Win2003 Server and IIS, and I'll dig into it on that asis.

However, I'm having another issue: I installed the same wiki on a Win2K box, and got it running as a CGI. Works perfectly. Installing MoinISAPI showed no error messages. However, once MoinISAPI was installed, any request for a page on the Wiki returns the following error message:

File "C:\MoinISAPI\MoinIIS.py", line 94, in HttpExtensionProc
  r = RequestISAPI(ecb)
File "C:\MoinISAPI\MoinIIS.py", line 161, in __init__
  self.accepted_charsets = self.parse_accept_charset(ac)
AttributeError: 'RequestISAPI' object has no attribute 'parse_accept_charset'

(MoinMoin version 1.5.2, MoinIIS v.3, win32api build 207, all Windows updates applied to Win2K and IIS.)

Question: Should I remove the CGI virtual directories before installing MoinISAPI?

Question: Is it appropriate to drop MoinISAPI directly into the /mywiki directory and install it from there, or is it better to put it someplace else (and have two copies of wikiconfig.py?

Answer: MoinISAPI needs the same virtual directory as CGI, one that contain some resources. MoinISAPI could be absolutely anywhere, its data and underlay directories could be placed with it or somewhere else, all you need is to alter wikiconfog.py properly. Actually I see no need to keep CGI having MoinISAPI up and running.

Tinyfish at 29-03-2007

I've modified the script to make it work for MoinMoin 1.5.7. This version hasn't been tested for long time, but seems stable so far. Thanks Sergey Chernov for the good script. The modified vesion is here: MoinIIS_for_1.5.py

Comments to older versions

Current version is 3. Issues below are supposed to be fixed, but are tested only on a few platforms.


When I run "MoinIIS.py install" or with the --server flag, I get the following:

C:\KevinData\WikiRaima>MoinIIS.py --server=krt01 install
Traceback (most recent call last):
  File "C:\KevinData\WikiRaima\MoinIIS.py", line 12, in ?
    sys.path.append('C:\Moin\Lib\site-packages')
NameError: name 'sys' is not defined

I am running it in the same folder as my wikiconfig.py. Is there something else I'm missing?

I put "import sys" at the top of MoinIIS.py and got a different error:

C:\KevinData\WikiRaima>MoinIIS.py install
Traceback (most recent call last):
  File "C:\KevinData\WikiRaima\MoinIIS.py", line 15, in ?
    from isapi import InternalReloadException
ImportError: No module named isapi

Then I added "import isapi" and got this error:

C:\KevinData\WikiRaima>MoinIIS.py install
Traceback (most recent call last):
  File "C:\KevinData\WikiRaima\MoinIIS.py", line 8, in ?
    import isapi
ImportError: No module named isapi

sergeych: well I forget to put import sys above os.path.append. Looks like you have no windows extenstions package installed (its from where isapi module comes from)


In my experiences:

-- SeungikLee 2005-11-10 02:17:48

Try to upgrade to MoinMoin 1.3.5+; my IIS-specific Request object is intended to run under this version instanse of MoinMoin. It should also work with later releases too.

Anyway. looks like it can't access wikiconfig.py. It must be in the same folder as MoinIIS.py. And it should be a vlaid wikiconfig.py file, suitable to run for .cgi instanse.

-- Sergeych

Now it works well on Moin 1.3.5, after inserted

sys.path.append('C:/MoinWiki-1.3.5/Lib/site-packages')

into MoinIIS.py before importing some from MoinMOin. The performance comparison should be estimated compared with original ones, and FastCGI ones. One buggy thing is that some css style is not applied to the pages generated from this isapi. From the html source, I found that it omits.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

comparing to the conventional one. I don't know whether this is a clue for the problem, it should be patched. -- SeungikLee 2005-11-10 04:02:46

Performance Report: I've compared 3 of deployments on windows. And the followings are my rough estimation.

In conclusion, I think that it's very helpful to the IIS users if this continues to be debugged and supported for 1.5 or later.

-- SeungikLee 2005-11-10 04:59:17


At least in earlier versions of iis, http status codes are not properly forwarded. The culprit is in the finish method, where it sets the response to "200 Ok" if the response has not been set. Um, the response never gets set :)

def finish(self):
        RequestBase.finish(self)
        headers = '\r\n'.join(self.all_headers).encode('utf8')
# begin patch
        response = self.getHeader('Status')
        if response:
            self.response = response
# end patch
        if not self.response: self.response = "200 Ok"
        self.ecb.SendResponseHeaders( self.response, headers )
     ...
    def getHeader(self,name):
        name = name.lower()+': '
        for x in self.all_headers:
            if x.lower().startswith(name):
                return x[len(name):]
        # raise "some string exception"
        return None

This grabs the response supplied by Moin if it is supplied, and sets our response code to it. --cwillu


Replacing setup_args with the following seems to make it work (note, this makes the drawing editor work too):

    def setup_args(self, form=None):
        from StringIO import StringIO
        ecb = self.ecb
        headers = {}
        headers['content-type'] = ecb.ContentType
        assert 'REQUEST_METHOD' in self.env
        assert 'QUERY_STRING' in self.env
        assert 'content-type' in headers
        data = StringIO()
        data.write(ecb.AvailableData)
        while data.len < ecb.TotalBytes:
            data.write(ecb.ReadClient())
        data.seek(0)
        if ecb.Method.upper() == "POST":
            form = cgi.FieldStorage(fp=data, environ=self.env, headers=headers)
        elif form==None:
            form = cgi.FieldStorage(fp=data, environ=self.env)
        return self._setup_args_from_cgi_form(form)

Of course this is really ugly and so deserves a cleanup; better than nothing.

--cwillu

Long term perspective

I found http://code.google.com/p/isapi-wsgi/ - if that works it could be a good long term alternative, as moin will move more and more in the WSGI direction.

(!) As moin 1.6.3+ already supports WSGI, no need to wait, you can start trying it right now.

-- ThomasWaldmann 2008-04-26 22:12:36

Confirmation:

MoinMoin: MoinMoin ISAPI (last edited 2015-10-16 05:56:54 by 141)