From 1f31a29249fd9fc205f4d1c690c6a71e9fd0bb35 Mon Sep 17 00:00:00 2001 From: Hernan Date: Fri, 17 Nov 2023 19:08:12 +0000 Subject: [PATCH 1/3] Fix data arg in CelerySignalProcessor.registry_delete_task --- django_elasticsearch_dsl/signals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_elasticsearch_dsl/signals.py b/django_elasticsearch_dsl/signals.py index 48f42249..8f8889c6 100644 --- a/django_elasticsearch_dsl/signals.py +++ b/django_elasticsearch_dsl/signals.py @@ -166,7 +166,7 @@ def prepare_registry_delete_related_task(self, instance): self.registry_delete_task.delay(doc_instance.__class__.__name__, bulk_data) @shared_task() - def registry_delete_task(doc_label, data): + def registry_delete_task(doc_label, bulk_data): """ Handle the bulk delete data on the registry as a Celery task. The different implementations used are due to the difference between delete and update operations. From 7e271b99fd62bf58d8bdc04ec0d10709635028b8 Mon Sep 17 00:00:00 2001 From: Hernan Date: Fri, 17 Nov 2023 19:15:56 +0000 Subject: [PATCH 2/3] Improved some comment spelling in CelerySignalProcessor --- django_elasticsearch_dsl/signals.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/django_elasticsearch_dsl/signals.py b/django_elasticsearch_dsl/signals.py index 8f8889c6..758f39b3 100644 --- a/django_elasticsearch_dsl/signals.py +++ b/django_elasticsearch_dsl/signals.py @@ -110,18 +110,18 @@ class CelerySignalProcessor(RealTimeSignalProcessor): Allows automatic updates on the index as delayed background tasks using Celery. - NB: We cannot process deletes as background tasks. - By the time the Celery worker would pick up the delete job, the - model instance would already deleted. We can get around this by - setting Celery to use `pickle` and sending the object to the worker, - but using `pickle` opens the application up to security concerns. + Please note: We are unable to process deletions as background tasks. + If we were to do so, the model instance might already be deleted by the time + the Celery worker picks up the delete job. One workaround could be configuring + Celery to use pickle and sending the object to the worker. + However, employing pickle introduces potential security risks to the application. """ def handle_save(self, sender, instance, **kwargs): """Handle save with a Celery task. - Given an individual model instance, update the object in the index. - Update the related objects either. + Given an individual model instance, update the document in the index. + Update the related objects as well. """ pk = instance.pk app_label = instance._meta.app_label From 4d324f23d037816cd6dfe0c98ea23c90dd8046ea Mon Sep 17 00:00:00 2001 From: Hernan Date: Fri, 17 Nov 2023 19:29:46 +0000 Subject: [PATCH 3/3] Improved docstring of prepare_registry_delete_task --- django_elasticsearch_dsl/signals.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/django_elasticsearch_dsl/signals.py b/django_elasticsearch_dsl/signals.py index 758f39b3..9699b654 100644 --- a/django_elasticsearch_dsl/signals.py +++ b/django_elasticsearch_dsl/signals.py @@ -179,7 +179,20 @@ def registry_delete_task(doc_label, bulk_data): def prepare_registry_delete_task(self, instance): """ - Get the prepare did before database record deleted. + Prepares the necessary data for a deletion task before a database record is deleted. + + This function is called prior to the deletion of a database record. Its main role + is to gather all relevant data related to the record that is about to be deleted + and to queue a task that will handle the index update. The actual index update is + performed by the `registry_delete_task`, which is triggered asynchronously. + + Parameters: + - instance (Model): The Django model instance that is about to be deleted. + + The function iterates over documents related to the instance, collects necessary + data, and prepares bulk data representing the delete action. This data is used + to queue the `registry_delete_task`, which will handle updating the index to + reflect the deletion. """ action = 'delete' for doc in registry._get_related_doc(instance): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy