Archive for November, 2006

Minimal Python HTTP Dispatch Server: simpledispatch

2

I was looking for a way to put together simple HTTP based services with as little fuss as possible. In this case that meant having a self contained script with minimal external dependencies, skipping even apache (for various reasons such as not having root access on the box, not having apache installed, and just plain being lazy).

I’m also generally interested in script-only http servers and wanted to experiment.

Unfortunately I didn’t immediately find anything that fit the bill, so I decided to hack something up. I’m fairly happy with the result. This is not intended to be a general purpose HTTP server; in fact, it’s intended to be the opposite, serving small, specialized, self contained services. It doesn’t serve static content (files and images); Apache and others do a great job of that already.

To use it, you simply define a function called method_yourmethod and add it to the handler, either by extending the base handler or by monkey patching it in. This method becomes accessible as http://yoursite/yourmethod . Parameters are passed to it by just adding more to the url path; for example: http://yoursite/yourmethod/param1/param2/param3 . These are received by method_yourmethod as a list.

Under the hood it uses introspection via getattr to find a method to match the URL, and passes it the remaining parameters.

The easiest way to understand it is to download the simpledispatch.py file and look at the use_simpledispatch.py for usage examples. Run simpledispatch.py and access it at http://localhost:8000/test/a/b/c . Run use_simpledispatch.py and try it out at http://localhost:8000/extended and http://localhost:8000/monkey .

Yes, I do know about the myriad wonderful frameworks out there (django is my framework of choice at the moment) and I do know about twisted. simpledispatch is not a replacement for any of those; it’s just a very simple dispatcher.

Please Hack the Wiimote for PC Use

3

Check out these videos of people using the Nintendo Wii. Looks very cool. Here’s a family with two little kids trying it together. I could see trying that with my boys.

I’m actually tempted to buy the thing – supposedly it’s $250, although I’ve only seen it in bundles costing > $600 and it seems to be sold out right now.

But I’m more excited about hacking this. Not the Nintendo to try to get free games (although surely somebody will do that too), but hacking on the Wiimote. I want to hook it up to a PC and be able to program to it.

Writing games is getting easier. Given a library that encapsulates the Wiimote controller, you could open it up a to a world of hacking on innovative interfaces.

Anyway, I’m excited about cheap, defacto-standardized, fairly accurate motion sensing being unleashed on the world. It’s about time we had something new in mass-market human-computer interfaces.

So somebody please hack it, release the interface, wrap it up in Python, and let the fun begin!

UPDATE:  It’s hacked! Windows drivers are now available.

Python JMS Equivalent?

4

I’m thinking through an implementation that I’d like to scale some day. Essentially it’s a message processing system with a small bit of state to pass around. Mostly it’s a matter of handing messages off between various workers.

In Java world I’d do this with threads. If I wanted to think across boxes I’d throw in some sort of persistent queue, likely JMS.

But I’m in the Python world. I could do threads (btw, how well do threads work in Python in both windows and linux?), but I’m on a non-threads kick at the moment and would like to go the multi-process/message passing route.

What I’m looking for is a JMS equivalent for Python – a persistent, reliable message passing system with a clean API that can be used on a single machine/single processor system just as well as on a multi-machine/multi-processor network of systems.

I looked briefly – I could do something with xmpp, there’s spread, or I could put the queue in a database. But none of them are satisfactory.

How are people doing persistent queues in Python? Is there a JMS like device?

Setting up pageant for password-less login

2

This is a recipe for setting up pageant.exe on windows to allow ssh login without having to type in the password every time. Mainly for my own notes.

From putty download: putty.exe , puttygen.exe, pageant.exe .

Run pageant. Take the default options and move your mouse around till your key is generated.

Put in a passphrase and save the private key somewhere private. Save the public key.

Login to the remote host using putty.

vi ~/.ssh/authorized_keys

Paste in the stuff from puttygen, the part that says “Public key for pasting into…”

Close puttygen. Run pageant.exe. A little terminal with a hat icon appears in your windows task bar area. Right click it. Select add key and add in your private key that you had saved earlier. It’ll ask for a password, type it in.

That’s it, you’re done. Now you can putty to your remote host and it won’t ask you for a password. Particularly useful for things like winscp, svn+ssh, etc.

Django Book And The Future of Publishing

0

The Django folks have started publishing preview copies of The Django Book for free on the Web. This is similar in concept to Beta Books, except that this one’s free – you don’t have to pay for anything. Excellent.

But far more interesting is the comment and feedback system. They’ve taken Jack Slocum’s comment system and integrated it into the book. Jack’s comment system provides comments in context – you attach comments directly to the part of the text you’re commenting on.

The results are fascinating. There are already 261 comments on the first three chapters, and it’s only been out there for 6 days. I looked over a few of the comments and the vast majority are quality, often pointing out real issues or adding value to the text.

A printed book is easier to read (easier on the eyes, and there’s always the read-on-the-crapper factor). It also allows you to concentrate – no IM or email competing for your attention.

But for a technical book, I could see preferring the online marked-up version. This form of navigating a book is pretty interesting – the book is still edited down to a reasonable size and covers the appropriate level of detail, but the comments are there to provide depth where you’re interested.

Evangelical Pastor Buys Acid From Male Prostitute, Throws it Away , Doesn’t Sleep With Him

0

This is just priceless.

The Rev. Ted Haggard admitted Friday he bought methamphetamine from a male prostitute but maintained he never had sex with the man and never used the drug.

I bought it for myself but never used it. I was tempted but I never used it,” he said, smiling constantly from the driver’s seat of his pickup truck as he answered questions from reporters outside his home.

Jones [the male prostitute] said his acquaintance with Haggard – whom he knew as “Art” – lasted about three years, with Haggard calling him every month or so and paying him for sex. Haggard’s middle name is Arthur.

Jones said he learned Haggard’s real name about six months ago while watching a History Channel program on which Haggard was interviewed. Jones began researching Haggard and discovered his church’s positions on same-sex marriage.

“I got to tell you, I started getting pissed,” he said.

SOA is not complex. You are just dumb.

1

Via SOA Facts.

Experiences with DabbleDB?

1

I’ve been interested in DabbleDB for some time now, since they first showed up on the scene with their Under The Radar demo. I immediately pointed a friend at them, who in turn got very excited and spent a few days integrating his app with theirs, only to give up as he hit scaling issues on the DabbleDB side (his data set was too large).

I took another look, prompted by Jon Udell’s latest screencast (via Kedrosky), and I understand better what they’re going after. Seems they’re targeting small business, where DabbleDB is used as a stand-alone app, very much as Excel on the Web with sharing built in.

I could see that working for them, although the install base and more importantly experience base around Excel is a tough nut to crack. And then there is Google Docs of course, which is not nearly as rich of an experience, but if the use case is excel-on-the-web-with-sharing, it may be good enough.

But for me the more interesting side is being able to “mash up” DabbleDB into my own app. I have several side projects where having a nice tabular view that could explode out into the rich experience that Dabble offers would be fantastic. You’re using my Web app, you come to a nice innocent looking table, you click on it, and you have all the power of Dabble underneath. I love the idea of being able to build multiple views in DabbleDB and offer them as pages in my app – I’d get a much richer experience in my app without having to build the backend and the UI for the data parts.

However, as it stands the UI is not easily transplantable into my app. The data is offered out in reasonable ways, via an API and RSS, but I already have the data. I’m interested in DabbleDB the app. I don’t think I can host my apps on Dabble, nor can I integrate the Dabble interface into into my app.

DabbleDB could be my online database in a cloud. I can interact with my data via APIs, which is very nice. However, given that Dabble is a startup, do I really want to trust them with my data?

Funny how that works – with Amazon’s S3 I have the opposite reaction. I’d like to back up all my data to it, because being in Amazon’s data center gives me a feeling of security. There’s also Google Base, but Google is starting to creep me out with their data policies and their customer support (disclosure: I work at Yahoo!, but they started creeping me out before I started a Yahoo!).

So let’s forget mashups and go back to the shared-online-excel use case. Recently I was exchanging data with the business folks and ran into a dataset that would be nicely served by DabbleDB: the query and report capabilities would be very useful, as would online collaboration. But I don’t think that would work either: I seriously doubt corporate policy would allow me to host confidential data on external servers. I realize there’s plenty of data in the world that doesn’t need to be secured, but that excludes pretty much all business / corporate data in any reasonably sized company.

Maybe I’m just not the target audience for DabbleDB at the moment. But I’d like to be. I like the app and I like the idea. I’d like to find a way to use it.

Have you had experience with DabbleDB or other hosted apps? What do you think?