Many-To-Many Subsets

I'm modeling game results in a Django app I'm working on. A team consists of one or more players, and players may be on multiple teams -- a ManyToManyField in Django. Then there are locations that maintain a list of players (not teams) who are authorized to play there, and players may be authorized for multiple locations -- another ManyToManyField. What I wanted to find was, given a location, a list of teams whose players are all authorized to play at that location.

Read the rest of this entry...

Searchable Models

If you happen to be one of about 4 people that actually reads this, you may notice I added a search box to the sidebar. What's far more interesting is the code behind it. I posted a snippet containing the code I wrote to accomplish this. Basically, it's just some convenience code to avoid having to drop down to SQL or use triggers for the simple case of having a model where you want certain fields to be full-text searchable. A SearchableModel will, by default, automatically update it's search index when you call its save() method. The API is documented at the top of the snippet, so I won't duplicate it here, but I will share the search view this site uses:

Read the rest of this entry...

Re-introducing pydmtx

Just a quick note: pydmtx is now included with libdmtx. The project had been on hiatus to avoid any legal/patent problems, but is back and better than ever. Check out what's new here.

Read the rest of this entry...

Introducing pydmtx

pydmtx is a thin python wrapper around libdmtx. It does one and only one thing (for now) -- it creates DataMatrix barcode images.

Read the rest of this entry...

FastCGI, et. al.

I've been wanting to drop mod_python since the day I installed it. After the saga of setting it up, I was left feeling unclean. So I sat down yesterday and started downloading new versions of stuff. Apache, mod_fastcgi, Python, Subversion, PHP... you name it. My biggest concerns were upgrading to Python 2.5, and switching this site (and others) from mod_python to mod_fastcgi. But I sure am glad I did. Deploying a Django site was never my favorite thing to do under mod_python, but with mod_fastcgi, it became an almost joyous experience.

Read the rest of this entry...

Sitemap Redux

Well, that was fast. My sitemap app made it's way into Django proper. I added a couple new convenience classes and fixed up the ping_google function. Adrian took it the rest of the way and cleaned up my code and documentation. You can read about it here, or have a look at the documentation. Viva Django!

Read the rest of this entry...

Google Sitemaps

Just wanted to share some code that I wrote to generate a sitemap.xml file in Google's sitemap format. It's a django application modeled off of django.contrib.syndication. Here's the rub:

Read the rest of this entry...

Fun with counting

This entry is more of a note to myself, as any SQL guru will probably read it and think less of me for just now realizing it. My problem was as follows.

Read the rest of this entry...

On Indentation

I don't understand why so many otherwise intelligent programmers insist on using spaces to indent lines of code. The whole purpose of a tab is to advance the cursor to a specific position. These positions are customizable in every capable editor out there. Why force your formatting on everyone who has to read or edit your code? It's not like you sit there and hit the spacebar 2, 3, 4, or 8 times; you hit tab and tell your editor to translate it to spaces. In fact, you go to great lengths to have your editor pretend a group of spaces at the beginning of a line is one unit -- a tab, if you will. What's the point? A tab is the semantically correct equivalent.

Read the rest of this entry...

AJAX Harmony

Today, I reveal the secrets behind the flickr photo box to your left. Alternately: how easy and fun web programming can be with good tools. Also alternately: a shameless plug for software I like, including my own.

Read the rest of this entry...