Make a function to delegate permission object rendering to some
    other (foreign key) field of an object.

def make_get_perms_object(perms_objs):
    """Make a function to delegate permission object rendering to some
    other (foreign key) field of an object.

    """
    def retfn(obj, action):
        if action in perms_objs:
            if perms_objs[action] is None:
                return None
            else:
                return get_perms_object(getattr(obj, perms_objs[action]),
                                        action)
        else:
            return get_perms_object(obj, action)
    return retfn