A blog about one guys quest to learn Python, Django and Google App Engine.
Feed: http://appengineguy.com/atom.xml

tisdag 29 juli 2008

Internationalization problems

Just ran into a few issues when trying to get internationalization working - these are tips I really could have used.

First, you need to create a directory called locale in your django application dir (i.e. the directory where you keep the views.py file).

To create the language files, you need to run django-admin.py makemessages from your django app dir. When I ran this, I got this:

Error message: makemessages is an unknown command on django-admin.py
Took me a while to figure this one out - this can occur if django is not installed - i.e if you just have it in your app engine dir, it won't cut it. You need to run setup.py install to sort it out. Bastard.

You need to have gettext on your system for the localization to work. Unix systems have this per default, but Windows does not, and getting it to work involves a frickin' moon process. This is what you need to do:

  1. Download and unzip gettext into some directory.
  2. Add the /bin subdirectory of that directory to your path.
  3. Download iconv.dll and slap it into the bin dir.
  4. Download intl.dll (I have no idea what this is) and slap it into the bin dir.

Sorry for this jumbled up post - it's written at 2AM after fighting with this for way too long.

tisdag 22 juli 2008

Gist: Hosted version control of code snippets

Okay, this is just seriously cool. GitHub (hosting provider for the open source version control system git) has just launched Gist - a version control system for little snippets of code. I'll be trying it out on my code examples in the blog, henceforth.

onsdag 16 juli 2008

How to do AVG and SUM in Google App Engine Data Store

People who are used to relational databases, which is pretty much every gosh-darned web developer out there, will run into pretty much the same obstacles with the app engine datastore - one of them is How the heck do I do SUM or AVG?. Yeah, due to how the Data Store works - you cannot do any kind of aggregate query. Instead, you have to re-calculate the totals at write time and keep them in a Counter instead. Like this:


And you use it like this...


Performance note: It is a slightly bad idea to do counters like I have done above, but in my defence, I have done it for simplicity. In practice, it's important that you shard your counters.

As always, comments and questions are always welcome!