From 3ea46e9dc7d4c1a4866b439438d9678c86d951b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Mon, 29 Aug 2016 16:00:16 +0200 Subject: [PATCH] Fixed autoupdate for deleted instances. Fixed #2329. --- openslides/utils/autoupdate.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/openslides/utils/autoupdate.py b/openslides/utils/autoupdate.py index 5cddda1f4..3fb448ab5 100644 --- a/openslides/utils/autoupdate.py +++ b/openslides/utils/autoupdate.py @@ -109,19 +109,23 @@ def inform_changed_data(instance, is_deleted=False): # Instance has no method get_root_rest_element. Just ignore it. pass else: + message_dict = { + 'collection_string': root_instance.get_collection_string(), + 'pk': root_instance.pk, + 'is_deleted': is_deleted and instance == root_instance, + 'dispatch_uid': root_instance.get_access_permissions().get_dispatch_uid(), + } + # If currently there is an open database transaction, then the following # function is only called, when the transaction is commited. If there # is currently no transaction, then the function is called immediately. - def send_autoupdate(): + def send_autoupdate(message): try: - Channel('autoupdate.send_data').send({ - 'collection_string': root_instance.get_collection_string(), - 'pk': root_instance.pk, - 'is_deleted': is_deleted and instance == root_instance, - 'dispatch_uid': root_instance.get_access_permissions().get_dispatch_uid()}) + Channel('autoupdate.send_data').send(message) except ChannelLayer.ChannelFull: pass - transaction.on_commit(send_autoupdate) + + transaction.on_commit(lambda: send_autoupdate(message_dict)) def inform_changed_data_receiver(sender, instance, **kwargs):