Latest News >> 2008-12-25

Dear Reddit,

2008-12-24

Ruby Is So Nice

2008-12-16

My RubyFringe presentation is available online at InfoQ:

2008-12-15

Back in the day I took an electrical engineering course at UBC on the five senses and what
we can do with them using technology. When it came to sound, we had to sit through this
excruciating series of videos of nerds trying to rock out with wands, sticks, balls, helmets,
pretty much anything that wasn’t an instrument. Every video demonstrated a horribly dressed geek
waving his little thing around at random with no rhythmic sense making noise. It was awful,
and when it was over I said, “You know, the problem with all of that music is you just can’t
dance to it.”

I’m working on a fun application that will use my nifty Son Of Sam email
server. I mentioned it once before months ago, but SoS is a simple
yet very powerful SMTP server written in Python. It basically lets you
write an email application the way you would write a modern web application.
Instead of stupid milter or pipes off of aliases in some weirdo M4 macro
config file, you create actual application code in nicely organized
source files.

How SoS works is it uses the Python asyncore and smtpd libraries to receive
email and process it, then it treats them the same way a web application
framework would: as a request. You then have a set of handlers that process
the message based on routings, and your handlers can then:

  • Hook into databases using SQLAlchemy (or anything).
  • Modify the message, drop it, SPAM filter it, greylist, etc.
  • Forward it on to a relay host.
  • Send other emails in response.
  • Track complex conversations involving multiple emails.

SoS also uses a simple little Finite State Machine library I wrote to keep
track of what’s going on. Since SMTP doesn’t have the concept of a
a request with data like HTTP does, you need a way to track a conversation
process. Using an FSM, each email received causes steps in the FSM to
transition, so you can process the conversation accurately. SoS does a
simple pickle of the FSM for each handler and you just do your thing
inside that.

What I did this weekend was start a fun little side project (more on that
later) and then I managed to connect it to
web.py and made them share the same SQLAlchemy model.
I then have the email application own the data model, and the web front-end
simply lives off that.

If you wanna play with the code, feel free to check out the Bazaar
repository by doing:

bzr branch http://zedshaw.com/repository/sos

Then you can take a look at the code. Installing it will probably be a pain in
the ass, but email me if you’re interested in trying it. I probably need to
work through a few people doing an install to get the instructions right.

The thing to check out is the sample directory in the source tree. That shows
you how the FSM works and how an application is laid out.