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

Reply via email to