Blog of Rob Galanakis (@robgalanakis)

Relearning python, day 6: Please serve me!

I wrote last time about all the difficulty I had with deciding on a UI framework.  Well, it turns out that was nothing compared to trying to get a server up and running.

I suppose I should say first that I have no experience doing web programming.  None.  I have some experience writing server/client apps, that were all WCF based.  I expected difficulties with python, but nothing like this.

My goal was clear- develop an RPC-like service interface that I can call from pyjamas.  So, first thing, I implement an XMLRPC server, based on SimpleXMLRPCServer.  Wow, that was easy!

Wait.  pyjamas cannot use XMLRPC because it isn’t a supported module.  They suggest JSONRPC.  Alright, well, no biggie.  Right?

Well unfortunately, there’s nothing so simple as SimpleXMLRPCServer for jsonrpc.  Even SimpleJSONRPC, because nothing I tried on the client seemed to work.  So began evaluating a dozen modules, looking for what should have been very simple.

I looked at the pyjamas JSONRPC example.  But it used CGI, and I need a persistent service.  I am not a Unix programmer and do not know how to, and don’t care to, set up mod_python, which apparently allows you to run python in Apache or some shit that I don’t want to care about.

So I looked at anything with jsonrpc in the name.  There are well over 20 modules that hit ‘jsonrpc’ at pypi.python.org.  Including ones that seem to conflict (how many are used with ‘import jsonrpc’?  At least two, from what I saw).  Keep trying, nothing works.

Alright, let’s up the ante.  Let me try stackless- can you even make a server in that?  Well I couldn’t, and I can’t remember the problems.  Well let’s look at Twisted.  Wait, zope.interfaces needs to be installed.  OK, got that.  Alright, following directions, and… fuck, that example didn’t work.  Why?  Can’t remember.  Alright, let me look at PyZeroMQ.  Easy install doesn’t work on Windows.  Shocker.  I’ll use the MSI.  There we go.  Whoops, that example didn’t work.  Wait, I need to download and build ZeroMQ myself?  Are you fucking kidding me?  Here we go.  Wow, build problems.  So surprised.  Huh?  Wait, this examples working.  Did I have to build/install?  I don’t know.  Sort of working now… ok, lots of good examples that seem to be mostly working.  I can do this.  I am scared to see what’ll happen when I move from a local to a remote server, though.  Well, let’s clean up some of this crap… wait, I am scared to think about the dependency tree here, and have no idea what is or is not safe to remove.

Ultimately I have no idea if ZeroMQ is what I want or will do just what I need, but it was the only thing that ended up working reasonably well (I only struggled with it for 1-2 hours before using it successfully!).  My guess is I will have several more hours trying to figure out how to make it work with pyjamas.  But at least this whirlwind of problems, so rapid and severe I can’t even recall all the issues, has subsided for now.

This situation is unforgivable.  It is representative of a huge ‘lie’ about python in particular and a problem with the OSS situation in particular.  I’ll have more to say about it soon.