Added 'locate' call in creation forms to avoid NotYet exception when registering contents
--- a/src/pyams_form/form.py Wed Mar 11 11:58:00 2015 +0100
+++ b/src/pyams_form/form.py Fri Mar 20 17:29:54 2015 +0100
@@ -43,6 +43,7 @@
from zope.component import queryUtility
from zope.interface import implementer, alsoProvides, Interface
from zope.lifecycleevent import Attributes, ObjectCreatedEvent
+from zope.location import locate
from zope.schema.fieldproperty import FieldProperty
from pyams_form import _
@@ -264,8 +265,12 @@
def createAndAdd(self, data):
registry = self.request.registry
+ # create object
object = self.create(data)
registry.notify(ObjectCreatedEvent(object))
+ # set parent temporarily to avoid NotYet exceptions
+ locate(object, self.context)
+ # update object properties before adding it
self.update_content(object, data)
self.add(object)
registry.notify(FormObjectCreatedEvent(object, self))