If you've read this blog before, perhaps you know that I keep my Django projects in a simple and flexible directory structure. I've written not one, but two posts about it earlier.
To be honest I'm quite proud of this setup. It fixes several things that the semi-standard Django project layout does not address. Most importantly it keeps my PYTHONPATH in a single directory.
Recently I have ported several projects to Django 1.0, which was a painful experience. However, some sites remain, for example rssepisodes.com which I haven't worked on for months. Today I decided that I had to fix a few bugs, so I eagerly cd'ed into the directory and tried to start the development server.
Now if you're like me you've completely forgotten that your PYTHONPATH contains Django-1.0 which of course is completely incompatible with the Subversion checkout that this code requires. No problemo you say, just check out the required revision. And of course that is what I did. But since my ~/python/django symlink points to ~/src/django-1.0/django I have to update that link. (~/python being my PYTHONPATH).
I must admit. I love stupid shell scripts. So I quickly created the following scripts. Now I run them whenever I need to change my django symlink.
$ cat ~/bin/use_django_7209.sh
#!/bin/bash -x
CURR=$PWD
cd $HOME/python
rm django
ln -s $HOME/src/django-svn-7209/django django
cd $CURR
And when I want to switch back:
$ cat ~/bin/use_django_1.0.sh
#!/bin/bash -x
CURR=$PWD
cd $HOME/python
rm django
ln -s $HOME/src/django-1.0/django django
cd $CURR
Sure, it's dead simple. It's basic. It's the next step from hello, world.
But it freaking works! And it saves me 30 seconds a few times a day.