Back to index

plone3  3.1.7
getPortalTypeList.py
Go to the documentation of this file.
00001 ## Script (Python) "getPortalTypeList"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=
00008 ##title=
00009 ##
00010 
00011 from Products.CMFCore.utils import getToolByName
00012 
00013 pt_tool = getToolByName(context, 'portal_types')
00014 plone_utils = getToolByName(context, 'plone_utils')
00015 normalizeString = plone_utils.normalizeString
00016 
00017 type_info = pt_tool.listTypeInfo()
00018 
00019 excluded_ids = {
00020     'TempFolder': None,
00021     'CMF Document': None,
00022     'CMF Event': None,
00023     'CMF Favorite': None,
00024     'CMF File': None,
00025     'CMF Folder': None,
00026     'CMF Image': None,
00027     'CMF Large Plone Folder': None,
00028     'CMF Link': None,
00029     'CMF News Item': None,
00030     'CMF Topic': None,
00031     'ATCurrentAuthorCriterion': None,
00032     'ATDateRangeCriterion': None,
00033     'ATDateCriteria': None,
00034     'ATListCriterion': None,
00035     'ATPathCriterion': None,
00036     'ATRelativePathCriterion': None,
00037     'ATPortalTypeCriterion': None,
00038     'ATReferenceCriterion': None,
00039     'ATBooleanCriterion': None, 
00040     'ATSelectionCriterion': None,
00041     'ATSimpleIntCriterion': None,
00042     'ATSimpleStringCriterion': None,
00043     'ATSortCriterion': None,
00044 }
00045 
00046 result = []
00047 for item in type_info:
00048     item_id = item.getId()
00049     if item_id not in excluded_ids:
00050         result.append({
00051             'id': normalizeString(item_id),
00052             'icon': item.getIcon(),
00053         })
00054 
00055 result = [(x['id'], x) for x in result]
00056 result.sort()
00057 result = [x[-1] for x in result]
00058 
00059 return result