Get an object from the database given an entity and the content key.

    :param entity: Class type of the object to retrieve.
    :param key: Array that defines the path of the value inside the message.

def get_object_from_content(entity, key):
    """Get an object from the database given an entity and the content key.

    :param entity: Class type of the object to retrieve.
    :param key: Array that defines the path of the value inside the message.
    """
    def object_from_content_function(service, message):
        """Actual implementation of get_object_from_content function.

        :param service: SelenolService object.
        :param message: SelenolMessage request.
        """
        id_ = get_value_from_content(key)(service, message)
        result = service.session.query(entity).get(id_)
        if not result:
            raise SelenolInvalidArgumentException(key, id_)
        return result
    return object_from_content_function