[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS - ContainerTraversable.py:1.1.2.1

Martijn Pieters mj@zope.com
Mon, 3 Dec 2001 17:08:12 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS
In directory cvs.zope.org:/tmp/cvs-serv23382/lib/python/Zope/App/OFS

Added Files:
      Tag: Zope-3x-branch
	ContainerTraversable.py 
Log Message:
Implementation of unrestrictedTraverse, with new interface and feature
ITraversable. Include a default ITraversable implementation, and one for
containers. Note: No security assertions yet.


=== Added File Zope3/lib/python/Zope/App/OFS/ContainerTraversable.py ===
# Copyright (c) 2001 Zope Corporation and Contributors.  All Rights Reserved.
# 
# This software is subject to the provisions of the Zope Public License,
# Version 1.1 (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.

from Zope.App.Traversing.ITraversable import ITraversable
from IContainer import IReadContainer
from Zope.Exceptions import NotFoundError

class ContainerTraversable:
    """Traverses containers via getObject"""

    __implements__ = ITraversable
    __used_for__ = IReadContainer

    def __init__(self, container):
        self._container = container

    def traverse(self, name, furtherPath):
        next = self._container.getObject(name, None)
        if next is None:
            raise NotFoundError, name
        return next