Back to index

plone3  3.1.7
hasIndexHtml.py
Go to the documentation of this file.
00001 ## Script (Python) "hasIndexHtml"
00002 ##title=Find out if this folder has an index_html page
00003 ##bind container=container
00004 ##bind context=context
00005 ##bind namespace=
00006 ##bind script=script
00007 ##bind subpath=traverse_subpath
00008 ##parameters=
00009 from AccessControl import Unauthorized
00010 from Products.CMFPlone.utils import base_hasattr
00011 # It's silly but because this is often called on the parent folder, we must
00012 # ensure we have permission.
00013 try:
00014     if not context.isPrincipiaFolderish:
00015         return False
00016 except Unauthorized:
00017     return False
00018 
00019 # Use the BTreeFolder API if possible
00020 if base_hasattr(context, 'has_key'):
00021     # BTreeFolder's has_key returns numeric values
00022     return context.has_key('index_html') and True or False
00023 elif 'index_html' in context.objectIds():
00024     return True
00025 else:
00026     return False