From 473f604b38763c4246655740ea484fc0c3cdf9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 24 Jan 2013 16:22:59 +0100 Subject: [PATCH] notify on added/modified objects, necessary to get backrefs to work --- src/collective/dms/thesaurus/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/collective/dms/thesaurus/utils.py b/src/collective/dms/thesaurus/utils.py index 0789a62..350aa63 100644 --- a/src/collective/dms/thesaurus/utils.py +++ b/src/collective/dms/thesaurus/utils.py @@ -5,6 +5,9 @@ from zope.app.intid.interfaces import IIntIds from z3c.relationfield import RelationValue from Products.Five.browser import BrowserView +from zope.event import notify +from zope.lifecycleevent import ObjectAddedEvent, ObjectModifiedEvent + class ImportJson(BrowserView): def __call__(self): @@ -25,6 +28,7 @@ class ImportJson(BrowserView): self.context.invokeFactory('dmskeyword', term_id, title=term.get('title')) object = getattr(self.context, term_id) + notify(ObjectAddedEvent(object)) try: term_intids[term_id] = self.intids.getId(object) except KeyError: @@ -39,5 +43,6 @@ class ImportJson(BrowserView): object = getattr(self.context, term_id) object.related = [RelationValue(term_intids[x]) for x in term.get('related', [])] object.broader = [RelationValue(term_intids[x]) for x in term.get('parents', [])] + notify(ObjectModifiedEvent(object)) return 'OK'