diff --git a/CHANGES.rst b/CHANGES.rst index 57988ed..50cbd5c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,9 @@ Changelog 1.2.15 (unreleased) ------------------- -- Nothing changed yet. +- WEB-4088 : Add after commit hook to reduce bad image upload to odwb because of the transaction speed + New contact hasn't time to go from private to published state ?! + [boulch] 1.2.14 (2024-06-28) diff --git a/src/imio/directory/core/subscribers.py b/src/imio/directory/core/subscribers.py index cf2c7e0..03ded88 100644 --- a/src/imio/directory/core/subscribers.py +++ b/src/imio/directory/core/subscribers.py @@ -16,6 +16,7 @@ from zope.lifecycleevent.interfaces import IAttributes import os +import transaction def set_default_entity_uid(contact): @@ -114,15 +115,20 @@ def published_contact_transition(obj, event): if not IAfterTransitionEvent.providedBy(event): return if event.new_state.id == "published": - request = getRequest() - endpoint = OdwbEndpointGet(obj, request) - endpoint.reply() + kwargs = dict(obj=obj) + transaction.get().addAfterCommitHook(send_to_odwb, kws=kwargs) if event.new_state.id == "private" and event.old_state.id != event.new_state.id: request = getRequest() endpoint = OdwbEndpointGet(obj, request) endpoint.remove() +def send_to_odwb(trans, obj=None): + request = getRequest() + endpoint = OdwbEndpointGet(obj, request) + endpoint.reply() + + def mark_current_entity_in_contacts_from_other_entities(obj, event): changed = False entities_to_treat = []