[Zope] Re: Index Problem - Index randomly breaks/changes

Tres Seaver tseaver at palladion.com
Fri Mar 7 12:12:11 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ryan Smith wrote:
> Tres - I am 98% sure I found the source of my problem.  I thought I
> was getting a copy of something back, when really I was getting a
> pointer to it.  So I was changing the catalog.   I am still slightly
> confused as to how it fixed itself (probably was due to data being
> cached).
> 
> In my code I have -
>            reqAccesses = results[index].getAccess
> 
>        for access in usrAccesses :
>            if access in reqAccesses :
>                 reqAccesses.remove(access)
> 
> I am getting a reference though, so when I do remove() I am changing
> the actual catalog values.
> 
> It looks like it is fixed by doing
> reqAccesses = results[index].getAccess.copy()
> 
> 
> I would like to thank you though for helping me deal with my
> stupidity.  This one was really stumping me since it seemed as though
> my code wasn't always involved.

Ah, I missed that you were mutating the list:  copying it means that you
leave the original untouched.  Glad that works for you!


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH0Xdr+gerLs4ltQ4RAsCZAJwJMj+Z/rP9hE2pWjEqIzy0DpkSRgCfS9FV
jfEm4SOgojbZUKnOuT5lTmE=
=z8D0
-----END PGP SIGNATURE-----


More information about the Zope mailing list