Best Day Ever

Today has definitely been the best day after the birth of my son:

  • We found a place to move to in Idaho
  • We’re going to get DSL
  • My phone bill was reduced by 25% per month
  • I got Half-Life and CounterStrike working under WINE
  • I had the best game of poker in my life, one game lasted 4 hrs 30 mins with a $240 pot for the winner, I came in second so broke even but it was incredible – I laid the smack down on three pretty awesome players

I really don’t think it gets much better than that. Thank you, and good night!

Shortening URLs in Mailman

Mailman is a great mailing list manager, and tonight I learnt how to implement my own functions.
Contrary to the FAQ, there is actually a really good way to extend the functionality of Mailman and it’s quite easy too.

Mailman uses python scripts called handlers, which are kept in mailman/Mailman/Handlers/. Each script contains a method (def, function, whatever you want to call it) called “process” which is automatically passed three arguments.

Basically in here you can do anything you would in a normal python script. The ‘msg’ variable that is actually an instance of a class which contains all of the message data (headers, body, and much other data). Once you’re done, put your new script in the above directory and add it to the GLOBAL_PIPELINE list in mailman/Mailman/mm_cfg.py (this file gets default from Defaults.py, copy anything you need from Defaults.py and put it in mm_cfg.py).
If you’re interested in doing any hacking of messages, look at Decorate.py in the above directory. I was able to make a very simple but effective URL shortener. Every message sent to my mailing lists now gets saved to a database and a new shorter URL is put after the original. If anyone would like to see the code, let me know 🙂

twisted.web and Method Not Allowed

Today I was developing a little application using Python’s Twisted framework. Everything was going as well as could be expected until I tried to POST some data to the application.

“Method Not Allowed
Your browser approached me (at /) with the method “POST”. I only allow the methods here.”

Googling for the answer, I found suggestions to add the following line to my application:
allowedMethods = (‘GET’, ‘POST’)
Unfortunately that doesn’t work by itself.

exarkun on irc.freenode.net/#twisted.web said my application was probably missing a render_POST method, which was correct. The problem was fixed by adding:
render_POST = render_GET
after my render_GET() method.