[Zope] odd iteration semantics in ZPT

dman dman@dman.ddts.net
Tue, 7 May 2002 12:50:45 -0500


--+pHx0qQiF2pBVqBT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


I created a collection and iterator class in an External Method for
use by my web app.  I implmented the iterator protocol introduced by
python 2.2, but also included a __getitem__ method to provide the
"old" iteration mechanism.  For various reasons, the client of my
iterator needs to know some information regarding where in the
iteration process the iterator is at.

I had little trouble making the iterator itself, but I kept getting
odd assertion errors and minor defects in the way data was retrieved
from my iterator.  I managed to track it down to the fact that
__getitem__ is called twice with 0 as the index.  The sequence of
index values looks like :  [0, 0, 1, 2, 3, 4, 5, 6, 7, 8]
I can work around this anomaly by resetting my iterator every time the
index is 0.

Is this a bug in zope?  (I expect that the bug is in ZTUtils/Iterator.py)

I'm using zope 2.5.1, python 2.1.3, debian 3.0.

-D

--=20

The way of a fool seems right to him,
but a wise man listens to advice.
        Proverbs 12:15
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg


--+pHx0qQiF2pBVqBT
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjzYE/UACgkQO8l8XBKTpRTXhQCdHuaZFhyHGyky+5fZtwZytYzy
TucAn0p1hIDbjGHYkJE07nPMYLiFyBr1
=G+9y
-----END PGP SIGNATURE-----

--+pHx0qQiF2pBVqBT--