Tag Archives: web

Pylons and Apache with repoze.who BasicAuth

To be able to use Basic Authentification in repoze.who running in a wsgi app in your Apache installation, you need to tell Apache to WSGIPassAuthorization. An Apache configuration like this will do:

# Setup mod_wsgi
WSGIPythonHome /var/www/pylons/runtime
WSGIScriptAlias /myApp /var/www/pylons/myApp/mod_wsgi/dispatch.wsgi
WSGIPassAuthorization On
 
<directory /var/www/pylons/myApp/mod_wsgi>
Order deny,allow
Allow from all
</directory>

The importanat part here is

WSGIPassAuthorization On

This will pass HTTP authorisation headers through to the WSGI application.

Sources: Repoze-dev Mailing List, modwsgi Wiki

Generating Faults in Pylons XMLRPCController

This might seem easy enough, but it took me a while to get it right since the Pylons documentation is a bit misleading here, really. It says you should use xmlrpc_fault from pylons.controllers.xmlrpc but that’s actually not working if you’re doing something like:

from pylons.controllers.xmlrpc import xmlrpc_fault
...
return xmlrpc_fault( 101, "My Error" )

This will wrap an xmlrpclib.Fault into a pylons.controllers.util.Reponse object which will fail to marshal with something like:

TypeError: cannot marshal <class 'pylons.controllers.util.Response'> objects </class>

The correct way to do it is:

import xmlrpclib
...
return xmlrpclib.Fault( 101, "My Error" )

Connecting Apache2 and Tomcat6

If you ever need to serve Tomcat applications through Apache2, here is a quick guide on how to do this on Ubuntu.

Continue reading