Commit 992f2968 authored by Jérome Perrin's avatar Jérome Perrin

Don't assume that an UnboundLocalError means that the type based script is not

found, simply check if _getTypeBasedMethod returns None


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25608 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c0b016a7
...@@ -76,13 +76,11 @@ class BudgetCell(Predicate, MetaNode): ...@@ -76,13 +76,11 @@ class BudgetCell(Predicate, MetaNode):
Return a calculated title. Return a calculated title.
""" """
script = self._getTypeBasedMethod('asTitle') script = self._getTypeBasedMethod('asTitle')
try: if script is not None:
title = script() return script()
except UnboundLocalError: raise UnboundLocalError,\
raise UnboundLocalError,\
"Did not find title script for portal type: %r" %\ "Did not find title script for portal type: %r" %\
self.getPortalType() self.getPortalType()
return title
security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory') security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory')
def getCurrentInventory(self, **kw): def getCurrentInventory(self, **kw):
...@@ -108,13 +106,11 @@ class BudgetCell(Predicate, MetaNode): ...@@ -108,13 +106,11 @@ class BudgetCell(Predicate, MetaNode):
Return consumed budget. Return consumed budget.
""" """
script = self._getTypeBasedMethod('getConsumedBudget') script = self._getTypeBasedMethod('getConsumedBudget')
try: if script is not None:
result = script(src__=src__) return script(src__=src__)
except UnboundLocalError: raise UnboundLocalError,\
raise UnboundLocalError,\
"Did not find consumed budget script for portal type: %r" % \ "Did not find consumed budget script for portal type: %r" % \
self.getPortalType() self.getPortalType()
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableBudget') security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableBudget')
def getAvailableBudget(self): def getAvailableBudget(self):
...@@ -129,11 +125,9 @@ class BudgetCell(Predicate, MetaNode): ...@@ -129,11 +125,9 @@ class BudgetCell(Predicate, MetaNode):
Return Engaged budget. Return Engaged budget.
""" """
script = self._getTypeBasedMethod('getEngagedBudget') script = self._getTypeBasedMethod('getEngagedBudget')
try: if script is not None:
result = script(src__=src__) return script(src__=src__)
except UnboundLocalError: raise UnboundLocalError,\
raise UnboundLocalError,\
"Did not find engaged budget script for portal type: %r" % \ "Did not find engaged budget script for portal type: %r" % \
self.getPortalType() self.getPortalType()
return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment