From: David G. <svn...@pl...> - 2010-03-01 07:11:22
|
Author: davisagli Date: Mon Mar 1 07:11:15 2010 New Revision: 34424 Modified: plone.app.layout/trunk/CHANGES.txt plone.app.layout/trunk/plone/app/layout/icons/icons.py Log: don't break when trying to return the portal_type title as icon description, with a missing portal_type Modified: plone.app.layout/trunk/CHANGES.txt ============================================================================== --- plone.app.layout/trunk/CHANGES.txt (original) +++ plone.app.layout/trunk/CHANGES.txt Mon Mar 1 07:11:15 2010 @@ -4,6 +4,10 @@ 2.0b5 - Unreleased ------------------ +- Make icon descriptions' lookup of portal_type title less brittle for missing + portal_types (fall back to the portal_type id). + [davisagli] + - Further optimize the related_items view by avoiding an algorithm with quadratic complexity. [hannosch] Modified: plone.app.layout/trunk/plone/app/layout/icons/icons.py ============================================================================== --- plone.app.layout/trunk/plone/app/layout/icons/icons.py (original) +++ plone.app.layout/trunk/plone/app/layout/icons/icons.py Mon Mar 1 07:11:15 2010 @@ -58,7 +58,11 @@ def description(self): context = aq_inner(self.context) tt = getToolByName(context, 'portal_types') - return tt.get(self.brain['portal_type']).Title() + fti = tt.get(self.brain['portal_type']) + if fti is not None: + return fti.Title() + else: + return self.brain['portal_type'] class CMFContentIcon(BaseIcon): @@ -83,7 +87,11 @@ def description(self): context = aq_inner(self.context) tt = getToolByName(context, 'portal_types') - return tt.get(self.obj.portal_type).Title() + fti = tt.get(self.brain['portal_type']) + if fti is not None: + return fti.Title() + else: + return self.brain['portal_type'] class FTIContentIcon(BaseIcon): |