Exemplo n.º 1
0
def add_to_index(obj_identifier, **kwargs):
    object_path, pk = utils.split_obj_identifier(obj_identifier)
    model_class = utils.get_model_class(object_path)
    instance = model_class.objects.get(pk=pk)

    index = site.get_index(model_class)
    index.backend.update(index, [instance])
Exemplo n.º 2
0
    def get_model_class(self, object_path):
        """Fetch the model's class in a standarized way."""
        model_class = utils.get_model_class(object_path)

        if model_class is None:
            self.log.error("Could not load model from '%s'. Moving on..." % object_path)
            return None

        return model_class
 def get_model_class(self, object_path):
     """Fetch the model's class in a standarized way."""
     model_class = utils.get_model_class(object_path)
     
     if model_class is None:
         self.log.error("Could not load model from '%s'. Moving on..." % object_path)
         return None
     
     return model_class
Exemplo n.º 4
0
def add_to_index(obj_identifier, **kwargs):
    object_path, pk = utils.split_obj_identifier(obj_identifier)
    model_class = utils.get_model_class(object_path)
    try:
        instance = model_class.objects.get(pk=pk)
    except model_class.DoesNotExist, exc:
        retries_remaining = add_to_index.max_retries - kwargs['task_retries']
        logger.warn("Could not find %s with pk=%s, will retry %d more times", model_class.__name__, pk,
                    retries_remaining)
        add_to_index.retry(exc=exc)
Exemplo n.º 5
0
def add_to_index(obj_identifier, **kwargs):
    object_path, pk = utils.split_obj_identifier(obj_identifier)
    model_class = utils.get_model_class(object_path)
    try:
        instance = model_class.objects.get(pk=pk)
    except model_class.DoesNotExist, exc:
        retries_remaining = add_to_index.max_retries - kwargs['task_retries']
        logger.warn("Could not find %s with pk=%s, will retry %d more times",
                    model_class.__name__, pk, retries_remaining)
        add_to_index.retry(exc=exc)
Exemplo n.º 6
0
def delete_from_index(obj_identifier, **kwargs):
    object_path, pk = utils.split_obj_identifier(obj_identifier)
    model_class = utils.get_model_class(object_path)

    index = site.get_index(model_class)
    index.remove_object(obj_identifier)
Exemplo n.º 7
0
def delete_from_index(obj_identifier, **kwargs):
    object_path, pk = utils.split_obj_identifier(obj_identifier)
    model_class = utils.get_model_class(object_path)

    index = site.get_index(model_class)
    index.remove_object(obj_identifier)