The iterator support leads to problems for us - acquisition wrappers are lost during iteration. Here is an example that uses __iter__:
from Acquisition import Implicit
class B(Implicit):
def __iter__(self):
for i in range(5):
yield i, self.aq_parent
class A(Implicit):
pass
a = A()
a.b = B()
for (i, parent) in a.b:
print i, parent
'self.aq_parent' fails here, as 'self' inside __iter__ isn't acquisition wrapped.
Worse is that *existing* code that has worked for years (namely ParsedXML) suddenly breaks, as it uses __getitem__ based iteration. The problem now is that this *always* uses iterators now, instead of using the old fallback. This means acquisition wrappers are lost within __getitem__ too now:
from Acquisition import Implicit
class B(Implicit):
def __getitem__(self, i):
if i == 5:
raise IndexError()
return i, self.aq_parent
class A(Implicit):
pass
a = A()
a.b = B()
for (i, parent) in a.b:
print i, parent
We do not know whether the implementation before this bugfix worked better with __iter__ but in any case we'd then again have the original reported issue that __getitem__ breaks.
We are seeing this issue appear in Zope 2.11.3, to which we're trying to port Silva, which relies on ParsedXML.
The iterator support leads to problems for us - acquisition wrappers are lost during iteration. Here is an example that uses __iter__:
from Acquisition import Implicit
class B(Implicit):
def __iter__(self):
for i in range(5):
yield i, self.aq_parent
class A(Implicit):
pass
a = A()
a.b = B()
for (i, parent) in a.b:
print i, parent
'self.aq_parent' fails here, as 'self' inside __iter__ isn't acquisition wrapped.
Worse is that *existing* code that has worked for years (namely ParsedXML) suddenly breaks, as it uses __getitem__ based iteration. The problem now is that this *always* uses iterators now, instead of using the old fallback. This means acquisition wrappers are lost within __getitem__ too now:
from Acquisition import Implicit
class B(Implicit):
def __getitem__(self, i):
if i == 5:
raise IndexError()
return i, self.aq_parent
class A(Implicit):
pass
a = A()
a.b = B()
for (i, parent) in a.b:
print i, parent
We do not know whether the implementation before this bugfix worked better with __iter__ but in any case we'd then again have the original reported issue that __getitem__ breaks.
We are seeing this issue appear in Zope 2.11.3, to which we're trying to port Silva, which relies on ParsedXML.