I have two content objects (both are containers) but I cannot add one
to another as give here :

   def create(self, data):
       square = Square()
       square.name = data['name']
       square.description = data['description']
       company = Company()
       company.name = data['companyname']
       company.description = data['companydescription']
       square['Comp1'] = company
       ...
       return square

It was working in 3.2, now NotYet error is coming in 3.3. Here is the traceback:

2006-05-20T11:07:46 ERROR SiteError http://192.168.1.10:8080/+/AddSquare.html%3D
Traceback (most recent call last):
 File "/megadisk/zopy/z33/lib/python/zope/publisher/publish.py", line
133, in publish
   result = publication.callObject(request, obj)
 File "/megadisk/zopy/z33/lib/python/zope/app/publication/zopepublication.py",
line 161, in callObject
   return mapply(ob, request.getPositionalArguments(), request)
 File "/megadisk/zopy/z33/lib/python/zope/publisher/publish.py", line
108, in mapply
   return debug_call(obj, args)
  - __traceback_info__: <security proxied
zope.app.pagetemplate.simpleviewclass.SimpleViewClass from
/megadisk/zopy/tzope/lib/python/websquare/browser/squareform.pt
instance at 0x41b6402c>
 File "/megadisk/zopy/z33/lib/python/zope/publisher/publish.py", line
114, in debug_call
   return obj(*args)
 File "/megadisk/zopy/z33/lib/python/zope/formlib/form.py", line 746,
in __call__
   self.update()
 File "/megadisk/zopy/z33/lib/python/zope/formlib/form.py", line 727, in update
   result = action.success(data)
 File "/megadisk/zopy/z33/lib/python/zope/formlib/form.py", line 577,
in success
   return self.success_handler(self.form, self, data)
 File "/megadisk/zopy/z33/lib/python/zope/formlib/form.py", line 837,
in handle_add
   self.createAndAdd(data)
 File "/megadisk/zopy/z33/lib/python/zope/formlib/form.py", line 842,
in createAndAdd
   ob = self.create(data)
 File "/extra/myzope/lib/python/websquare/browser/squareform.py",
line 37, in create
   square['Comp1'] = company
 File "/megadisk/zopy/z33/lib/python/zope/app/container/sample.py",
line 86, in __setitem__
   setitem(self, self.__data.__setitem__, key, object)
 File "/megadisk/zopy/z33/lib/python/zope/app/container/contained.py",
line 593, in setitem
   notify(event)
 File "/megadisk/zopy/z33/lib/python/zope/event/__init__.py", line
23, in notify
   subscriber(event)
 File "/megadisk/zopy/z33/lib/python/zope/component/event.py", line
26, in dispatch
   for ignored in zope.component.subscribers(event, None):
 File "/megadisk/zopy/z33/lib/python/zope/component/_api.py", line
130, in subscribers
   return sitemanager.subscribers(objects, interface)
 File "/megadisk/zopy/z33/lib/python/zope/component/registry.py",
line 292, in subscribers
   return self.adapters.subscribers(objects, provided)
 File "/megadisk/zopy/z33/lib/python/zope/interface/adapter.py", line
535, in subscribers
   subscription(*objects)
 File "/megadisk/zopy/z33/lib/python/zope/component/event.py", line
33, in objectEventNotify
   adapters = zope.component.subscribers((event.object, event), None)
 File "/megadisk/zopy/z33/lib/python/zope/component/_api.py", line
130, in subscribers
   return sitemanager.subscribers(objects, interface)
 File "/megadisk/zopy/z33/lib/python/zope/component/registry.py",
line 292, in subscribers
   return self.adapters.subscribers(objects, provided)
 File "/megadisk/zopy/z33/lib/python/zope/interface/adapter.py", line
535, in subscribers
   subscription(*objects)
 File "/megadisk/zopy/z33/lib/python/zope/app/intid/__init__.py",
line 161, in addIntIdSubscriber
   key = IKeyReference(ob, None)
 File "/megadisk/zopy/z33/lib/python/zope/app/component/hooks.py",
line 96, in adapter_hook
   return siteinfo.adapter_hook(interface, object, name, default)
 File "/megadisk/zopy/z33/lib/python/zope/security/adapter.py", line
88, in __call__
   adapter = self.factory(*args)
 File "/megadisk/zopy/z33/lib/python/zope/app/keyreference/persistent.py",
line 41, in __init__
   raise zope.app.keyreference.interfaces.NotYet(object)
NotYet: <websquare.square.company.Company object at 0x41b6016c>

I tried to override CreateAndAdd like this:

   def createAndAdd(self, data):
       square = Square()
       square.name = data['name']
       square.description = data['description']
       event.notify(ObjectCreatedEvent(square))
       square = self.context.add(square)
       self._finished_add = True
       company = Company()
       company.name = data['companyname']
       company.description = data['companydescription']
       chooser = INameChooser(square)
       name = chooser.chooseName('Company', company)

       square[name] = company
       ...
       return square

And this worked, but is it necessary to override createAndAdd for this?
(INameChooser could have been used in the earlier case also)

Thanks,
Baiju M
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to