Features of a good Django plugin

Well, my opinion on them anyway.

A while back I wanted to allow openid logins on my site. A simple problem which a few plugins released to the Django community make easier. However there’s quite a few of them (we list 4, there’s more) and none of them quite work the way I want.

So what’s wrong with them? Most of them define front end templates or particular models or a particular way of doing it. I don’t want that, I just want to make my application do openid authentication. So in frustration I have something which is a complete rip off of django-simple-openid from Benoît Chesneau.

When I’m building a website I do the following:

  • Create a user profile that contains custom user information. In this model I’d like to add in my openid information for the user.
  • Create an authentication backend that looks up the user profile defined before and logs the user in.
  • Create custom login, join, signout pages.
  • Create some middleware.

If I’m going to create all these steps I want a plugin that fits into this pattern. A lot of them end up being like contrib.comments, something you have to fight to get customised. As an example, here’s what I would like to see in an openid plugin:

  • Let me define my openid field on a model and make that a profile (standard Django practice)
  • Let me write my custom authentication backend (standard Django practice)
  • Document that I need to do the following views: login, login failed and signout and tell me the API to call
  • Document the data I need in forms to pass to the views
  • Provide an example set of models, views and template that I can choose to ignore
  • Let me write my own views and template (standard Django practice)

Thinking about it this mirrors the general Django philosophy in many ways. Perhaps a list for what a plugin should have:

  • No front end user interface
  • No standard models, just example models
  • No standard views, just example views
  • Unit tests
  • Documentation
  • An example implementation

The primary job of someone using your plugin is to integrate it with their application. Let’s make that a bit easier. 

Disclaimer: the new openid implementation from Simon Willison looks great. Although it does look worryingly complex, it seems to (at my quick glances over the code) accomplish the above.

Other disclaimer: it’s easy to say this standing up on my ivory tower since I haven’t actually released my openid library, because its a hacked up mess. Chances are as soon as I write about this, someone will come along and point out their Django openid plugin which does it just the way I want. I hope so.