Return the associated resource.

def get_resource(self):
        """Return the associated resource."""
        references = {"resource_id": None, "parent_id": None,
                      "grandparent_id": None}
        for model_cls, regexp in self._regexp.iteritems():
            match = regexp.search(self.resource_ref)
            if match is not None:
                references.update(match.groupdict())
                return model_cls.get(**references)

        raise exception.NotFound("No model available for %(resource_ref)r",
                                 resource_ref=self.resource_ref)