def search_index_signal_handler(instance, signal, **kwargs):
    """
    Signal handler for when indexable objects are saved or deleted.

    The indexing will run after the transaction commits, which will generally
    mean that all of the related ManyToMany data will be saved and ready.

    """

    if search_update_options['disabled']:
        return

    deleting = (signal is post_delete)

    if deleting:
        # When deleting, pass in an identifier string instead of the instance.
        # This is because Django will unset the instance's pk before the update
        # method runs, making it impossible to determine afterwards.
        item = get_identifier(instance)
    else:
        item = instance

    if search_update_options['async']:
        queue_update(item, remove=deleting)
    else:
        update_object(item, remove=deleting)
def search_index_signal_handler(instance, signal, **kwargs):
    """
    Signal handler for when indexable objects are saved or deleted.

    The indexing will run after the transaction commits, which will generally
    mean that all of the related ManyToMany data will be saved and ready.

    """

    if search_update_options["disabled"]:
        return

    deleting = signal is post_delete

    if deleting:
        # When deleting, pass in an identifier string instead of the instance.
        # This is because Django will unset the instance's pk before the update
        # method runs, making it impossible to determine afterwards.
        item = get_identifier(instance)
    else:
        item = instance

    if search_update_options["async"]:
        queue_update(item, remove=deleting)
    else:
        update_object(item, remove=deleting)
 def update_search_index():
     update_object(identifier, remove=remove, exception_handling=False)
Exemple #4
0
 def update_search_index():
     update_object(identifier, remove=remove, exception_handling=False)