def get_state_data(cls, entity):
        """
        Returns the state data for the given entity.

        This also works for unmanaged entities.
        """
        attrs = get_domain_class_attribute_iterator(type(entity))
        return dict([(attr,
                      get_nested_attribute(entity, attr.entity_attr))
                     for attr in attrs
                     if not attr.entity_attr is None])