def getProfile(createIfNeeded=False):
    # Annoying that we can't use django get_or_create() idiom here.  the
    # appengine equivalent get_or_insert() seems to allow querying by
    # key only.  I also ran into problems trying to wrap this in a
    # transaction.
    user = users.get_current_user()
    profiles = ImokUser.all().filter('account =', user).fetch(1)
    if profiles:
        profile = profiles[0]
    else:
        if createIfNeeded:
            profile = ImokUser(account=user)
        else:
            profile = None
    return profile