[zope2-tracker] [Bug 360761] Re: Aquisition, __iter__ and __getitem__ in Zope 2.12.0a1
Martijn Faassen
faassen at startifact.com
Fri Sep 25 11:23:10 EDT 2009
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.
** Changed in: zope2
Status: Fix Released => Incomplete
** Changed in: zope2
Status: Incomplete => New
--
Aquisition, __iter__ and __getitem__ in Zope 2.12.0a1
https://bugs.launchpad.net/bugs/360761
You received this bug notification because you are a member of Zope 2
Developers, which is subscribed to Zope 2.
More information about the zope2-tracker
mailing list