# HG changeset patch # User Thierry Florac # Date 1518879532 -3600 # Node ID f503181e8b77d0c5059ed3988e93584b922fe5e0 # Parent 84d2932b293fd2f020b52cdb68ff983e35fe0062 Use transaction annotations to avoid multiple document indexations diff -r 84d2932b293f -r f503181e8b77 src/pyams_content_es/index.py --- a/src/pyams_content_es/index.py Thu Feb 08 08:52:49 2018 +0100 +++ b/src/pyams_content_es/index.py Sat Feb 17 15:58:52 2018 +0100 @@ -56,7 +56,10 @@ def handle_modified_document(event): """Handle modified document""" document = event.object - ITransactionManager(document).get().addAfterCommitHook(index_document, kws={'document': document}) + transaction = ITransactionManager(document).get() + if 'pyams_content_es.index_document' not in transaction.extension: + transaction.addAfterCommitHook(index_document, kws={'document': document}) + transaction.extension['pyams_content_es.index_document'] = True @subscriber(IObjectRemovedEvent, context_selector=IDocumentIndexTarget)