Catch AttributeError when running under mod_wsgi

This is the code @night-crawler suggested in issue #15