@classmethod
def from_api_dict(cls, api_dict):
    """Factory method that instantiates Model subclasses from API-returned dicts."""
    inst = cls()
    for attr in cls.direct_attrs:
        if api_dict.has_key(attr.api_name):
            api_value = api_dict[attr.api_name]
        elif attr.may_be_absent:
            api_value = attr.default
        else:
            raise KeyError(
                "API did not return required '%s' value for '%s' object" %
                (attr.api_name, cls.__name__))
        setattr(inst, attr.local_name, attr.local_type(api_value))
    return inst
