Re: [Zope3-Users] object has no attribute '_SampleContainer__data'
Jim Fulton wrote: Tom Dossis wrote: Leticia Larrosa wrote: I get the following error: 'Service' object has no attribute '_SampleContainer__data' I implementend a simple subclass of SampleContainer, then changed to subclass BTreeContainer, but forget to delete existing instances created in Zope. A tell tale sign is you can no longer delete the broken instance(s) This sounds like a bug. Could you report this with a specific example? Jim I can remember exactly how I naively did this originally, but I can achieve it with a little sabotage.. class Bogus(BTreeContainer): pass ... bogus = Bogus() root['bogus'] = bogus = Bogus() del bogus.__dict__['_SampleContainer__data'] del root['f'] Traceback (most recent call last): : File .. /zope/interface/adapter.py, line 487, in subscribers subscribers = [subscription(*objects) File .. /zope/app/container/contained.py, line 177, in dispatchToSublocations for sub in subs.sublocations(): File .. /zope/app/container/contained.py, line 208, in sublocations for key in container: File .. /zope/app/container/sample.py, line 56, in __iter__ return iter(self.__data) AttributeError: 'Bogus' object has no attribute '_SampleContainer__data' Is this a bug because the container now fails to fulfill it's interface causing object propogation to fail? Is defensive programming desirable or appropriate? snippet1 from distpatchToSublocations subs = ISublocations(object, None) if subs is not None: for sub in subs.sublocations(): snippet2 from ContainerSublocations adapter def sublocations(self) container = self.container for key in container: yield container[key] -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] object has no attribute '_SampleContainer__data'
Tom Dossis wrote: Leticia Larrosa wrote: When a try to see the view of list of Service of one of the ServiceList I get the following error: 'Service' object has no attribute '_SampleContainer__data' I'm newcomer in zope 3 and any idea will be appreciated. Thanks in advance. Leticia Larrosa In addition to the previous reply; I experienced the above problem when.. I implementend a simple subclass of SampleContainer, then changed to subclass BTreeContainer, but forget to delete existing instances created in Zope. A tell tale sign is you can no longer delete the broken instance(s) This sounds like a bug. Could you report this with a specific example? Jim -- Jim Fulton mailto:[EMAIL PROTECTED] Python Powered! CTO (540) 361-1714http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] object has no attribute '_SampleContainer__data'
On Oct 3, 2005, at 9:29 PM, Leticia Larrosa wrote: AttributeError: 'Service' object has no attribute '_SampleContainer__data' Hi Leticia. It looks like your container overrides __init__ and, rather than deferring to the SampleContainer.__init__, you are trying to set the __data value in your own class. If you are not familiar with the magic pseudo-private '__*' behavior in Python, maybe you should read up on it. The immediate fix, though, is to change your current SampleContainer __init__. If now it looks something like this: class SampleContainer(BTreeContainer): # ... def __init__(self): # ... self.__data = self._newContainerData() # ... then delete than instantiation and instead do this: class SampleContainer(BTreeContainer): # ... def __init__(self): # ... super(SampleContainer, self).__init__() # this replaces the self.__data line # ... That should hopefully clear it up. If you need to change what is made as the data object, override _newContainerData (although that's where the btree mix in does its work!). Gary ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
RE: [Zope3-Users] object has no attribute '_SampleContainer__data'
Tom and Gary, thanks so much. Tom, was exactly the same problem !!!. Gary, I will review my knowledge about python following your advice ;) Regards, Leticia -Original Message- From: Tom Dossis [mailto:[EMAIL PROTECTED] Sent: Monday, October 03, 2005 8:09 PM To: Leticia Larrosa Cc: zope3-users@zope.org Subject: Re: [Zope3-Users] object has no attribute '_SampleContainer__data' Leticia Larrosa wrote: When a try to see the view of list of Service of one of the ServiceList I get the following error: 'Service' object has no attribute '_SampleContainer__data' I'm newcomer in zope 3 and any idea will be appreciated. Thanks in advance. Leticia Larrosa In addition to the previous reply; I experienced the above problem when.. I implementend a simple subclass of SampleContainer, then changed to subclass BTreeContainer, but forget to delete existing instances created in Zope. A tell tale sign is you can no longer delete the broken instance(s) -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users