Skip to content

Catching up

Published on: August 26, 2013    Categories: Django, Meta, Python

For a while now I’ve been pretty embarrassed by this site. Not by the visual design, or the functionality (though some bits have been lost along the way, for reasons that will become obvious in a moment), but by the fact that it was old. As in, over five years old. It was running on a bunch of ancient code that I’d written a long, long time ago, on an ancient Subversion checkout of Django — for the historians in the audience, it was pre-queryset-refactor — and was, frankly, not particularly well-built to begin with.

I’ve lately been feeling the same way about some other public-facing projects I’ve worked on, which just added to the feeling of embarrassment: everything was too old, or too badly-written, or both, which is a major deterrent to feeling motivated to work on and do things. Especially since something written for an ancient version of Django can’t really take advantage of new tools or features.

But, finally, that’s changing.

Shiny and new

First up, if you’re seeing this, then you’re seeing a brand-new codebase in live deployment. You can check out the full list of technology in use if you’re interested, but here are the highlights:

Getting there was a bit of effort, and sometime soon I’ll probably write about it in detail, but the biggest takeaway is that getting everything to run on Python 3 was… almost ludicrously easy.

Since that bears repeating: getting up and running on Python 3 was easy. If you go take a look through the code for my blog app, I think you’ll find all of about three lines that exist to take care of Python 2/3 compatibility, and they’re all from stuff that’s built in to Django, which has excellent documentation on how to write code that works on Python 2 and 3. Granted, a blog isn’t a terribly complex application, but most useful applications aren’t really terribly complex.

So if you’ve been holding off from a Python 3 migration for fear that it would be too difficult, or that the library support wasn’t there, you should probably stop being afraid. In my case, there was one library that wasn’t quite compatible, so I forked it, made a quick change, and deployed from that.

App maintenance

Part of getting to this point, of course, was porting some old apps — besides the blog — that I’d written a long time ago. It’s been a bit of a busy summer, so I’ve been taking that at a pretty leisurely pace. I actually started with something that I don’t even personally use anymore, a pretty simple module that does web-color-format conversions. That one actually just worked out of the box on Python 3.3, so I ended up not having to do anything. I’ll probably roll a new release of that soon, though, just to update the documentation and add the Python 3 trove classifiers (and clean up its PyPI listing while I’m in there).

Then I moved on to an actual Django application, though again a pretty simple one. It turned out to need a minor tweak for Python 3 string compatibility, and then it also just worked. My third Python 3 port was an application that I actually use on this site — django-contact-form powers my contact form.

That one was a bit more involved, not because of Python issues, but because I went ahead and updated it to use class-based views. The next release of that one will probably add proper i18n support, if there’s interest; someone submitted a pull request years ago for a translation, but I hadn’t got round to it in time to actually have it work.

Finally, I rewrote my ancient blog app, which I’ll cover in a bit more detail some other time, set up a Django 1.5 project skeleton and filled it in, and then went to work on the server side.

Altogether this has been a few weeks’ worth of my evening and weekend time (and, with two conferences, a work trip, and a couple of personal trips recently, I haven’t had a ton of evening/weekend time to spend on things). This morning I flipped the switch on the DNS, pointing to a new server running the Python 3 codebase.

The future (this site)

It feels really good to finally be up-to-date (at least for a little while; Django 1.6 is in beta already, and I do plan to upgrade as soon as possible after it releases, since it’s looking pretty hot). it feels really good to look at this site and not be embarrassed by how old and cruddy the code is. It feels good not to be discouraged from writing by knowing that I really ought to get around to rewriting and upgrading everything. And that’s a pretty powerful motivator.

My next significant project is probably going to be switching over to Persona for authentication; I’ve already had a chance to use it and see it in action (at the day job, we’ve been using Persona auth in production for a while), and lately I’ve been reading up a bit on how it works. There’s another whole post lurking in that, but it’s enough to say that I’ve been a lifelong skeptic of single-sign-on and federated-identity systems, and Persona has actually won me over. There’s Django integration available (with some Python 3 hiccups that I’ve reported and plan to see if I can help out with, so mkelly won’t kill me for reporting and running away), and it actually is just stupidly easy to plug in and use.

I’m also going to try an experiment with writing, since I desperately miss doing that. A few years ago I tried (and, due to some surprise travel plans, failed) to keep up with a “post-a-day” fad that a bunch of people were doing; I know I can’t maintain that sort of pace, but I am going to try for at least one a week, since I’ve got a few topics queued up and no further reason to feel embarrassed about my own site.

The future (other projects)

Meanwhile, I’ve been doing a lot of thinking about the collection of Django-related apps I’ve put out over the years, and debating just what I want to do with them. Some are as embarrassingly old as this site was. Some are even older. Some of them solve problems that no longer exist, or are no longer relevant. So I’ve been trying to make some tough decisions, and I’m not entirely done with that.

My personal philosophy on Django application design was articulated in the first public Django-related talk I ever gave (at the very first DjangoCon, no less). The slides are here, but the bullet-point version of that philosophy is:

  1. Do one thing, and do it well.
  2. Don’t be afraid to write a bunch of apps.
  3. Write for flexibility.
  4. Build to distribute.

Those are still pretty solid guiding principles, though these days I’d be inclined to add a couple more to the list:

  1. Solve an unsolved problem.
  2. Write something you personally care about.

That last one is a bit hand-wavy, since being paid to write code is certainly a motivation to care (and has caused me to care about things I otherwise never would have), but mostly I think it’s a mistake to be writing and trying to maintain something that you don’t personally have a stake in.

In case you can’t guess, this is the segue into talking about the elephant in the room: django-registration.

Many years ago, django-registration was my pride and joy. It was extensible and flexible despite also being clean and simple, it exemplified what I thought was right about how to write Django applications and it was, by a large margin, the most popular piece of personal code I’d ever written. And then time passed. It started growing, doing more things, getting more unwieldy, and generally being much less of what I’d consider to be good code. And then it started to rot.

Django 1.5 compatibility was a sore spot for a while, because — for multiple reasons — I just didn’t have the time to even review pull requests other people were sending in. And I was getting spammed, multiple times a day, by endless “+1” and “why isn’t this merged yet” comments that I couldn’t do anything about, which certainly didn’t help. I posted a comment mentioning that I had a partial rewrite done and would wrap it up at the PyCon sprints; that became django-registration 1.0, which was released right about then.

Except there were still issues:

All of which adds up to a sad but necessary conclusion: I should no longer be the maintainer of django-registration. As of today, I’m accepting proposals to hand it off; if you’re interested, get in touch and we’ll talk.

As for my other apps:

The present

In the meantime, I’m going to bask a bit in the glow of a shiny new Python-3-powered site, and put my time into getting ready for DjangoCon. I’ve been hitting the conference circuit pretty hard this summer, trying to ease back into the community after basically being devoured by work and non-tech-related things for over a year, and DjangoCon is the last stop on that tour. For the first time ever I’m not going to be speaking (though I am putting together a proposal for PyCon next year, so if you enjoy hearing my voice you can hopefully get your fix next spring in Montréal), but I’ll be there for the full conference + sprints and aiming to socialize and get back into the flow of things.