, Apache 2, WSGI, CGI, full software development joy experience

Post date: Apr 4, 2014 4:39:04 PM

Some times developing is fun. Sometimes it's just so frustrating. Here's one story.

I'm just curious, if anyone has used bottle with cgi. It was a breeze to create my app. But when installing it into production server, all traditional developer it hell broke lose.

1) Bottle CGI routing seems to be broken

2) MOD WSGI doesn't seem to work very well or easily with Python 3

It's just so wonderful when you know that you have alternatives. Ok, this doesn't work, let's try alternate approach, and it doesn't work either. Aaahh, complete developer enjoyment experience. Bottle code seems to be quite complex, but I'll try to get that routing fixed. Now I have the application working, but I'm using bottle root routing with my own router. Which doesn't make any sense at all. I've now played about three hours with thing that should be absolutely trivial, this is bit frustrating. Bottle is clearly broken, and now there are nasty edgy sharp glass shards everywhere.

Btw. If I check os.environ when running bottle via CGI, it's just fine. ['SCRIPT_NAME': '/testing', 'REQUEST_URI': '/testing'] but guess what, just like I said. Whatever the url says, it's always routed to / by bottle.

I'm still looking for solution. Potential discussion is in Google+ Python Community / my post.

Updated about one hour after the post:

Well, I got it finally fixed. After all I figured out that if I use rewrite and add path to script name, then it starts to work. So they're not using the request path, but script parameters instead. Now it works for both, direct links and directories and using pure CGI. Then I had some challenges to get the indexes working (root path). But it required additional configuration on Apache side, so it's routed correctly to the script root path. So ScriptAliasMatch doesn't work with bottle and you have to use RewriteEngine and DirectoryIndex to get things really working.

Btw. The site I wrote just as bottle practise is now open DNS-Hosts.