notify on added/modified objects, necessary to get backrefs to work
This commit is contained in:
parent
8d14f72eb3
commit
473f604b38
|
@ -5,6 +5,9 @@ from zope.app.intid.interfaces import IIntIds
|
||||||
from z3c.relationfield import RelationValue
|
from z3c.relationfield import RelationValue
|
||||||
from Products.Five.browser import BrowserView
|
from Products.Five.browser import BrowserView
|
||||||
|
|
||||||
|
from zope.event import notify
|
||||||
|
from zope.lifecycleevent import ObjectAddedEvent, ObjectModifiedEvent
|
||||||
|
|
||||||
|
|
||||||
class ImportJson(BrowserView):
|
class ImportJson(BrowserView):
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
|
@ -25,6 +28,7 @@ class ImportJson(BrowserView):
|
||||||
self.context.invokeFactory('dmskeyword', term_id,
|
self.context.invokeFactory('dmskeyword', term_id,
|
||||||
title=term.get('title'))
|
title=term.get('title'))
|
||||||
object = getattr(self.context, term_id)
|
object = getattr(self.context, term_id)
|
||||||
|
notify(ObjectAddedEvent(object))
|
||||||
try:
|
try:
|
||||||
term_intids[term_id] = self.intids.getId(object)
|
term_intids[term_id] = self.intids.getId(object)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -39,5 +43,6 @@ class ImportJson(BrowserView):
|
||||||
object = getattr(self.context, term_id)
|
object = getattr(self.context, term_id)
|
||||||
object.related = [RelationValue(term_intids[x]) for x in term.get('related', [])]
|
object.related = [RelationValue(term_intids[x]) for x in term.get('related', [])]
|
||||||
object.broader = [RelationValue(term_intids[x]) for x in term.get('parents', [])]
|
object.broader = [RelationValue(term_intids[x]) for x in term.get('parents', [])]
|
||||||
|
notify(ObjectModifiedEvent(object))
|
||||||
|
|
||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
Reference in New Issue