Hello from BarCampBoston

Hello from BarCampBoston

Greetings from Boston – specifically, BarCampBoston. My first “unconference”. Nerds galore.

The format is (mostly) half-hour talks from attendees on whatever subjects interest them – as long as other attendees have also expressed interest. It’s all tracked on a big board in the lobby. So far I’ve been in discussions involving localization, designing for technophobes, cloud computing, physics simulation in games, and Lisp. The level of interactivity is high – as is the collective expertise brought by the participants.

robots.txt via Django, in one line

A significant difference between developing Django sites versus static-HTML-based approaches (among which I count PHP and the like) is that static files, aka “media”, live in a dedicated spot.

Sometimes you need a piece of static content to be available at a specific URL outside your media root. robots.txt for example. This can be done in pure Django (i.e. without even touching your Apache configuration), and is especially nice if your robots.txt content is short. The example below serves a basic “keep out” configuration.

Django LogEntry to the rescue

If you use Django’s admin application, you’re familiar with its “Recent Actions” sidebar. It gives a simple summary of your latest edits, including clickable links to the relevant objects (not any ones you deleted, naturally, but ones you added or changed).

It’s probably not something you look at very often, unless you do such intensive work in the admin that you lose track of things.

Django stores that log data (via the admin’s LogEntry model) for all admin users, a fact which has caused me to repeatedly daydream about writing a custom view or two to display it. In other words, I’d like to let superusers browse all object editing history. Because sometimes you need to answer questions like “When was that changed?” and/or “Who changed it?”

Keeping emacs backup files tidy

In the shell, emacs is my editor of choice. However, it has one default behavior that has gotten in the way more often than it has helped – automatic generation of backup files in the same directory as the original.

Emacs is great for making quick edits to files on the web server. But I don’t want or need all those *~ files sitting around. The material is all in version control, so I can already revert to any point in history.

Email servers: how not to do it

I run my own mail server. I don’t consider myself an especially skilled administrator, so I shouldn’t point fingers. However, in recent weeks I’ve had the following experience more than once.

  1. A delivery-failure message arrives from an unfamiliar host.
  2. The (quoted) orginal message is nothing I ever sent.
  3. The recipient is unfamiliar to me.
  4. The “sender” of the original message is an email address I control, but not one I ever send mail with.
  5. OK, so this is backscatter.
  6. I email the postmaster suggesting they learn how to avoid sending it.
  7. The message to the postmaster bounces back because of some server misconfiguration.

Argh! Nothing spoils the catharsis of a good complaint like a bounce.

A tiny little dpaste.com API

When I created dpaste, I tried to make it both a simple browser-based tool and a simple RESTful API. With very little work you could write a script that created a new paste item with a single POST.

Over the life of the site a few people have discovered and played with that “secret” API. I’ve now made it a bit more official. The new API has its own URL (versioned, even!) and is more tolerant of missing data, just like the web form.

Making your way from PHP to Python and Django

“I’m a PHP programmer and I want to check out this Django thing. What should I do?”

I’ve been seeing this kind of question pop up more and more, and I have a few answers.

First-hand experience as well as many conversations with developers online have led me to the same conclusion: the curious person behind such a question should be encouraged and assisted. (I’ll call that person “Pat” for the rest of the post, for convenience and conscientious gender-neutrality.)