Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ CMF test utils.
00014 
00015 $Id: utils.py 71020 2006-11-01 15:42:13Z yuppie $
00016 """
00017 
00018 def has_path( catalog, path ):
00019     """
00020         Verify that catalog has an object at path.
00021     """
00022     if type( path ) is type( () ):
00023         path = '/'.join(path)
00024     rids = map( lambda x: x.data_record_id_, catalog.searchResults() )
00025     for rid in rids:
00026         if catalog.getpath( rid ) == path:
00027             return 1
00028     return 0
00029 
00030 def _setUpDefaultTraversable():
00031     from zope.interface import Interface
00032     from zope.component import provideAdapter
00033     from zope.traversing.interfaces import ITraversable
00034     from zope.traversing.adapters import DefaultTraversable
00035 
00036     provideAdapter(DefaultTraversable, (Interface,), ITraversable)