Friday, February 22, 2013

Wanderings, 2013-02-22

This post will contain "geeky stuff". You were warned.

Blender 2.66 released

Blender 2.66 was released yesterday. Some of the changes:
  • Cycles strand (hair) rendering;
  • Rigid body physics simulation (no more recording in the game engine!);
  • Dynamic topology;
  • New and more accurate particle fluid solver (I wonder why the new one is called the "classic" solver?);
  • Support for Retina displays.
You can view the release log here.

Lessons, failures and question marks at work

I've been working on a project that uses RapidSMS (and hence, Django), and I've had some ups and downs with it that I consider worth sharing.

rapidsms-admin.py no longer works

If, like I have, you've used RapidSMS before (in the grand days of version 0.9.6a) and you're upgrading beyond that version, I've news for you (if you've never upgraded beyond that version): rapidsms-admin.py does not work anymore, at least for creating new projects. Go to the RapidSMS documentation site and read the installation instructions. Yes, I know: the documentation on setting up a new project shouldn't be under installation instructions, but we live in an imperfect world. Oh, and you'll need Django 1.4 or greater.

Python's extended slice syntax is all sorts of awesome when you need it

An example is much clearer than explaining:

>>> # a rather contrived example, but please bear with me
>>> mylist = ['a', 1, 'I', 'b', 2, 'II', 'c', 3, 'III']
>>> mylist[::3] # starting with the first element, pick every third element
['a', 'b', 'c']
>>> mylist[1::3]
[1, 2, 3]
>>> mylist[2::3]
['I', 'II', 'III']

Guido's time machine is alive and well. Don't ask what I needed this for, by the way. Oh, and if anyone has an excellent solution for displaying code snippets on Blogger, I'm all ears.

By myself, I broke Django's ListView (I think)

I set up a ListView for my project, but I kept getting an empty page, even after I confirmed that I had data in my database. Of course, when you have to communicate progress, an empty page isn't terribly convincing that you're not just sitting on your behind. After going back and forth with it, I decided to ask in #django on Freenode, and it was confirmed my code and template had correct code. After some more kicking stuff back and forth, it turned out that even though I had set the context_object_name on the class, Django was still going with the default, object_list. So if you set up a ListView and things aren't working as they should, this may save you a couple of head-scratching moments.

Blowing things up with syncdb and createsuperuser

I like my development environment. But sometimes, it can be really annoying. Every time I drop and recreate the development database for a Django 1.4 project, I'd naturally want to run manage.py syncdb to recreate the tables and whatnot. But on my development machine, the environment variable LANG is not set, which causes creating a superuser with the management script to blow up. There are a couple of fixes:
  • Set the environment variable before creating the superuser using the management script
  • Do a little code-jitsu to do that.
The second is my preferred choice, especially since a friend has drummed into my head the usefulness of having local settings in a local_settings.py file. So, by way of helping someone else, and in order to remember, I add these lines to my local_settings.py:

import os

os.environ['LANG'] = 'en_US.UTF-8'

Found this fix on this Stackoverflow post (first comment on accepted answer). This has been fixed in Django 1.5, so until you upgrade, keep using the workaround.

No comments: