[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper - ContainmentIterator.py:1.1.2.1
Jim Fulton
jim@zope.com
Fri, 28 Dec 2001 13:58:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper
In directory cvs.zope.org:/tmp/cvs-serv24687
Added Files:
Tag: Zope-3x-branch
ContainmentIterator.py
Log Message:
Added containment iterators for wrapped objects.
=== Added File Zope3/lib/python/Zope/ContextWrapper/ContainmentIterator.py ===
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Revision information: $Id: ContainmentIterator.py,v 1.1.2.1 2001/12/28 18:58:40 jim Exp $
"""
from Zope.ContextWrapper import Wrapper, getinnercontext
class ContainmentIterator:
def __init__(self, obj):
self._ob = Wrapper(None, obj)
def __iter__(self):
return self
def next(self):
ob = self._ob
if type(ob) is not Wrapper:
raise StopIteration
ob = getinnercontext(ob)
self._ob = ob
return ob