[Product-Developers] ObjectInitializedEvent in a loop

Shrek Zhou zgwmike at hotmail.com
Sun May 22 16:30:13 UTC 2011


Hello, all
I have the following code snippet.  I call zope.event.notify in a loop to 
notify my new object. I debugged and the zope.event.notify is called many 
times, but the problem here is the event handler is only called once. What's 
going wrong? I am using Plone 4.1b2.

for rn in range(1,sheet.nrows):
                fields_map = blah blah.
                id = plone_utils.normalizeString(fields_map['phone'])
                if id not in self.context.contentIds():
                    id = self.context.invokeFactory(type_name="YeZhu",id=id, 
title=fields_map.pop('title'),**fields_map)
                    yezhu = getattr(self.context,id)
                    zope.event.notify(ObjectInitializedEvent(yezhu))


regards
Shrek 




More information about the Product-Developers mailing list