Exemple #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])
Exemple #2
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)
Exemple #3
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)
    def split_obj_identifier(self, obj_identifier):
        """
        Break down the identifier representing the instance.
        
        Converts 'notes.note.23' into ('notes.note', 23).
        """

        split_identifier = utils.split_obj_identifier(obj_identifier)
        if split_obj_identifier == (None, None):
            self.log.error("Unable to parse object identifer '%s'. Moving on..." % obj_identifier)
        return split_obj_identifier
    def split_obj_identifier(self, obj_identifier):
        """
        Break down the identifier representing the instance.
        
        Converts 'notes.note.23' into ('notes.note', 23).
        """

        split_identifier = utils.split_obj_identifier(obj_identifier)
        if split_obj_identifier == (None, None):
            self.log.error("Unable to parse object identifer '%s'. Moving on..." % obj_identifier)
        return split_obj_identifier
Exemple #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)
Exemple #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)