[Zope3-dev] Iterating over InternalPrincipal results in an
infinite loop.
Jim Fulton
jim at zope.com
Mon Aug 22 14:57:33 EDT 2005
Alec Munro wrote:
> Perhaps this is intended behaviour, but if you create an instance of
> InternalPrincipal,
AFAIK, InternalPrincipal is not part of a public API,
so you shouldn't do that ... but ...
> and then attempt to iterate over it, it will
> infinitely return None.
>
> The following code does the trick:
>
> from zope.app.authentication.principalfolder import InternalPrincipal
> joe = InternalPrincipal("joe", "123", "Joe")
> for key in joe:
> print key
>
> It took me a while to track this down, and now that I know what it is,
> I'm sure I can work around it, but I thought it would be worth
> bringing up. Here is InternalPrincipal's __getitem__
>
> def __getitem__(self, attr):
> if attr in ('title', 'description'):
> return getattr(self, attr)
This is bad. It doesn't seem to be used by anything/
I've removed this from the trunk and will remove it from
the 3.1 branch soon.
Thanks for pointing this out.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list