[Zope3-Users] Re: Creating objects in software space when making site

Michael Howitz mh at gocept.com
Tue Mar 7 07:36:00 EST 2006


Am Dienstag, den 07.03.2006, 12:49 +0100 schrieb Florian Lindner:
> Hello,
> I've tried from __init__ so content is self in my case (at least I think so):
> 
> from zope.app.component import site
> from zope.proxy import removeAllProxies
> 
> class Centershock(BTreeContainer, SiteManagerContainer):
>     __doc__ = ICentershock.__doc__
>     
>     implements(ICentershock)    
>         
>     def __init__(self):
>         """ Makes this object a site and add some required utitlies."""
>         bare = removeAllProxies(self)
>         sm = site.LocalSiteManager(bare)
>         self.setSiteManager(sm)
> 
> 
> That gives the wierd error:
> 
>   File "/home/florian/Zope3/src/zope/interface/adapter.py", line 481, in 
> subscribers
>     subscribers = [subscription(*objects)
>   File "/home/florian/Zope3/src/zope/app/container/contained.py", line 183, in 
> dispatchToSublocations
>     for sub in subs.sublocations():
>   File "/home/florian/Zope3/src/zope/app/container/contained.py", line 214, in 
> sublocations
>     for key in container:
>   File "/home/florian/Zope3/src/zope/app/container/sample.py", line 56, in 
> __iter__
>     return iter(self.__data)
> AttributeError: 'Centershock' object has no attribute '_SampleContainer__data'
> 
> 
> Any idea?

How about calling
 super(Centershock, self).__init__(*args, **kw)
But this will not work because during __init__ you have no context which
is needed by the site manager.

Try to subscribe to the ObjectAddedEvent.


-- 
Mit freundlichen Grüßen

Michael Howitz



More information about the Zope3-users mailing list