MoinMoin encoding issue

September 4, 2010

As mentioned in my previous post, the encoding in my MoinMoin wiki was somehow broken. When entering Danish characters on a page, they were turned into garbage (which persisted when switching to edit view). Surprisingly, I fixed this by accident today when making a change to improve the performance of the wiki.

It turns out that the preferred way to run a MoinMoin instance on Apache2 these days is with mod_wsgi. I’m not even sure what that is, except it has to do with running Python code in an Apache server via some daemons.

To install mod_wsgi:

sudo aptitude install libapache2-mod-wsgi

The only change needed in my Apache2 configuration was replacing this line:

ScriptAlias /w "/usr/share/moin/server/moin.cgi"  

with these lines:

WSGIScriptAlias /w /var/www/chopwiki/moin.wsgi

WSGIDaemonProcess chopwiki-daemon user=www-data group=www-data home=/var/www processes=5 threads=10 maximum-requests=1000 umask=0007

WSGIProcessGroup chopwiki-daemon

 

The “moin.wsgi” referenced above was copied from /usr/share/moin/server into /var/www/chopwiki but not modified. 

After making this change, the character encoding issue was gone as well! I have no idea why, and I’m not going to spend time finding out.

It seems like I’m going to be haunted by my disastrous server upgrade for some time to come.

The server has gitosis installed, which is what I use for serving my private Git repos. Now, when trying to clone a repo (from another computer), I suddenly got a stack trace:

/usr/bin/gitosis-serve:5: UserWarning: Unbuilt egg for setuptools [unknown version] (/usr/lib/python2.6/dist-packages)
  from pkg_resources import load_entry_point
Traceback (most recent call last):
  File "/usr/bin/gitosis-serve", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2655, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: gitosis==0.2
fatal: The remote end hung up unexpectedly

It turns out that this was because Python had been upgraded to 2.6. Fixing it was extremely easy: Re-install gitosis with the current version of Python:

git clone git://eagain.net/gitosis

cd gitosis

sudo python setup.py install

Now I just need to figure out how to fix the charset encoding in my MoinMoin wiki…

Today I stumpled upon this excellent presentation by David Beazley about Python’s global interpreter lock (GIL).

I knew about this lock already, and I knew that it prevents parallel execution of threads in Python. What I didn’t know is that performance actually suffers on multicore systems!

Of course there’s a logical explanation for this, and David took the time to dig into the code and find out what is going on. And he does a great job of explaining it to the rest of us.

Highly recommended if you want to know more about Python threading and signal handling.

Follow

Get every new post delivered to your Inbox.