From 992f296808eb154f733e8f5f3bf8a8dcba037887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 18 Feb 2009 15:00:53 +0000 Subject: [PATCH] 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 --- product/ERP5/Document/BudgetCell.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/product/ERP5/Document/BudgetCell.py b/product/ERP5/Document/BudgetCell.py index 8c6b0fa0b3..1ea5b07d4d 100644 --- a/product/ERP5/Document/BudgetCell.py +++ b/product/ERP5/Document/BudgetCell.py @@ -76,13 +76,11 @@ class BudgetCell(Predicate, MetaNode): Return a calculated title. """ script = self._getTypeBasedMethod('asTitle') - try: - title = script() - except UnboundLocalError: - raise UnboundLocalError,\ + if script is not None: + return script() + raise UnboundLocalError,\ "Did not find title script for portal type: %r" %\ self.getPortalType() - return title security.declareProtected(Permissions.AccessContentsInformation, 'getCurrentInventory') def getCurrentInventory(self, **kw): @@ -108,13 +106,11 @@ class BudgetCell(Predicate, MetaNode): Return consumed budget. """ script = self._getTypeBasedMethod('getConsumedBudget') - try: - result = script(src__=src__) - except UnboundLocalError: - raise UnboundLocalError,\ + if script is not None: + return script(src__=src__) + raise UnboundLocalError,\ "Did not find consumed budget script for portal type: %r" % \ self.getPortalType() - return result security.declareProtected(Permissions.AccessContentsInformation, 'getAvailableBudget') def getAvailableBudget(self): @@ -129,11 +125,9 @@ class BudgetCell(Predicate, MetaNode): Return Engaged budget. """ script = self._getTypeBasedMethod('getEngagedBudget') - try: - result = script(src__=src__) - except UnboundLocalError: - raise UnboundLocalError,\ + if script is not None: + return script(src__=src__) + raise UnboundLocalError,\ "Did not find engaged budget script for portal type: %r" % \ self.getPortalType() - return result -- 2.30.9