Commit bac66c42 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix except with no name.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4150 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7320b4e3
......@@ -88,7 +88,7 @@ class ActiveProcess(Base):
"""
try:
my_id = int(self.getLastId())
except:
except TypeError:
my_id = 1
while self.result_list.has_key(my_id):
my_id = my_id + 1
......
......@@ -31,6 +31,7 @@ from Acquisition import aq_base
from DateTime import DateTime
from Products.CMFActivity.ActivityTool import Message
from zLOG import LOG
from ZODB.POSException import ConflictError
# Error values for message validation
EXCEPTION = -1
......@@ -151,6 +152,8 @@ class Queue:
for k, v in kw.items():
if activity_tool.validateOrder(message, k, v):
return INVALID_ORDER
except ConflictError:
raise
except:
LOG('WARNING ActivityTool', 0,
'Validation of Object %s raised exception' % '/'.join(message.object_path),
......
......@@ -28,7 +28,7 @@
from Products.CMFCategory.Filter import Filter
from ZODB.POSException import ConflictError
from zLOG import LOG
class Renderer(Filter):
......@@ -184,6 +184,8 @@ class Renderer(Filter):
elif self.display_id is not None:
try:
label = value.getProperty(self.display_id)
except ConflictError:
raise
except:
LOG('WARNING: Renderer', 0,
'Unable to call %s on %s' % (self.display_id, value.getRelativeUrl()))
......
......@@ -440,7 +440,7 @@ An ERP5 Rule..."""
# We can now apply the calculated movements on the applied rule
try:
new_period = max(aggregated_period_dict.keys()) + 1
except:
except TypeError:
new_period = 0
for (c_period_number, calculated_dict) in calculated_period_dict.items():
# First, look for a potential found match
......@@ -555,7 +555,7 @@ An ERP5 Rule..."""
# the types which have not been matched later
try:
del aggregated_movement_dict[type]
except:
except KeyError:
pass
movements_created = setRemainingAggregatedMovementsToZero(aggregated_movement_dict = aggregated_movement_dict,
......
......@@ -594,7 +594,7 @@ identify a bank account."""
try:
priced_quantity = float(priced_quantity)
if priced_quantity == 0.0: priced_quantity = 1.0
except:
except TypeError:
priced_quantity = 1.0
error_list += ["Priced Quantity could not be converted for resource %s" % resource_id]
# source_base_price is the default base price.
......@@ -608,14 +608,14 @@ identify a bank account."""
base_price = resource.getBasePrice()
try:
base_price = float(base_price)
except:
except TypeError:
base_price = 0.0
error_list += ["Default base price could not be converted for resource %s" % resource_id]
if resource.hasSourceBasePrice():
source_base_price = resource.getSourceBasePrice()
try:
source_base_price = float(source_base_price)
except:
except TypeError:
source_base_price = 0.0
error_list += ["Source base price could not be converted for resource %s" % resource_id]
resource_quantity_unit = resource.getDefaultQuantityUnit()
......@@ -644,7 +644,7 @@ identify a bank account."""
new_base_price = resource_variation.getBasePrice()
try:
new_base_price = float(new_base_price)
except:
except TypeError:
new_base_price = 0.0
error_list += ["Default base price could not be converted for resource variation %s"
% resource_variation.id]
......@@ -655,7 +655,7 @@ identify a bank account."""
if resource_variation.hasSourceBasePrice():
try:
new_source_base_price = float(new_source_base_price)
except:
except TypeError:
new_source_base_price = 0.0
error_list += ["Source base price could not be converted for resource variation %s"
% resource_variation.id]
......@@ -703,7 +703,7 @@ identify a bank account."""
quantity = float(mapped_value.quantity)
is_variated_quantity = 1 # The variated quantity is 1
# when the quantity is defined by a variation matrix
except:
except TypeError:
error_list += ["Quantity defined by %s is not a float" % mapped_value.id]
# Update categories defined by the mapped value
base_category_list = mapped_value.getMappedValueBaseCategoryList()
......@@ -717,7 +717,7 @@ identify a bank account."""
new_base_price = resource_variation.getBasePrice()
try:
new_base_price = float(new_base_price)
except:
except TypeError:
new_base_price = 0.0
error_list += \
["Default base price could not be converted for resource variation %s"
......@@ -729,7 +729,7 @@ identify a bank account."""
new_source_base_price = resource_variation.getSourceBasePrice()
try:
new_source_base_price = float(new_source_base_price)
except:
except TypeError:
new_source_base_price = 0.0
error_list += \
["Source base price could not be converted for resource variation %s"
......@@ -742,7 +742,7 @@ identify a bank account."""
resource_quantity_unit)
try:
converted_quantity = float(converted_quantity)
except:
except TypeError:
converted_quantity = 0.0
error_list += ["Quantity could not be converted for resource %s" % resource.id]
# Convert price to unit price
......
......@@ -1373,12 +1373,7 @@ class ModuleTemplateItem(BaseTemplateItem):
module.setTitle(str(mapping['title']))
for name,role_list in list(mapping['permission_list']):
acquire = (type(role_list) == type([]))
try:
module.manage_permission(name, roles=role_list, acquire=acquire)
except:
# Normally, an exception is raised when you don't install any Product which
# has been in use when this business template is created.
pass
def _importFile(self, file_name, file):
dict = {}
......
......@@ -120,7 +120,7 @@ class DeliveryCell(MappedValue, Movement):
# Standard accessor
try:
result = Movement.getProperty(self, key, d=d)
except:
except AttributeError:
result = None
return result
......@@ -140,7 +140,7 @@ class DeliveryCell(MappedValue, Movement):
try:
price = float(price)
quantity = float(quantity)
except:
except TypeError:
price = 0.0
quantity = 0.0
total_quantity += quantity
......@@ -194,7 +194,7 @@ class DeliveryCell(MappedValue, Movement):
if len(item_result_list) == 1 :
try :
object = item_result_list[0].getObject()
except :
except AttributeError:
object = None
else :
object = None
......
......@@ -265,7 +265,7 @@ class DeliveryLine(Movement, XMLObject, XMLMatrix, Variated):
if len(item_result_list) == 1 :
try :
object = item_result_list[0].getObject()
except :
except AttributeError:
object = None
else :
object = None
......
......@@ -58,7 +58,7 @@ class Entity:
"""
try:
return self.getDefaultAddressValue().asText()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultAddressStreetAddress')
......@@ -68,7 +68,7 @@ class Entity:
"""
try:
return self.getDefaultAddressValue().getStreetAddress()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultAddressCity')
......@@ -78,7 +78,7 @@ class Entity:
"""
try:
return self.getDefaultAddressValue().getCity()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultAddressRegion')
......@@ -88,7 +88,7 @@ class Entity:
"""
try:
return self.getDefaultAddressValue().getRegion()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultAddressZipCode')
......@@ -98,7 +98,7 @@ class Entity:
"""
try:
return self.getDefaultAddressValue().getZipCode()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultTelephoneText')
......@@ -108,7 +108,7 @@ class Entity:
"""
try:
return self.getDefaultTelephone().asText()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultTelephoneNumber')
......@@ -118,7 +118,7 @@ class Entity:
"""
try:
return self.getDefaultTelephone().getTelephoneNumber()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultFaxText')
......@@ -128,7 +128,7 @@ class Entity:
"""
try:
return self.getDefaultFax().asText()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultFaxNumber')
......@@ -138,7 +138,7 @@ class Entity:
"""
try:
return self.getDefaultFax().getTelephoneNumber()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.View, 'getDefaultEmailText')
......@@ -148,7 +148,7 @@ class Entity:
"""
try:
return self.getDefaultEmail().asText()
except:
except AttributeError:
return ''
security.declareProtected(Permissions.ModifyPortalContent, 'setDefaultAddress')
......
......@@ -826,7 +826,7 @@ class Item(XMLObject, Amount):
if date is None:
try:
date = movement.getParent().getStopDate()
except:
except AttributeError:
pass
if date is not None and (at_date is None or date - at_date <= 0):
current_owner = movement.getDestinationSectionValue()
......@@ -834,12 +834,12 @@ class Item(XMLObject, Amount):
if current_owner is None:
try:
current_owner = movement.getParent().getDestinationSectionValue()
except:
except AttributeError:
pass
if previous_owner is None:
try:
previous_owner = movement.getParent().getSourceSectionValue()
except:
except AttributeError:
pass
if current_owner is not None and previous_owner != current_owner:
delivery_list.append(movement)
......
......@@ -152,7 +152,7 @@ identify a bank account."""
# Standard accessor
try:
result = Predicate.getProperty(self, key, d=d)
except:
except AttributeError:
result = None
return result
......
......@@ -303,7 +303,7 @@ class Movement(XMLObject, Amount):
if quantity is None:
return None
return quantity * price
except:
except TypeError:
return None
security.declareProtected(Permissions.AccessContentsInformation, 'getDestinationTotalAssetPrice')
......@@ -319,7 +319,7 @@ class Movement(XMLObject, Amount):
if quantity is None:
return None
return quantity * price
except:
except TypeError:
return None
# Causality computation
......@@ -528,7 +528,7 @@ class Movement(XMLObject, Amount):
quantity = self.getQuantity()
try:
quantity = float(quantity)
except:
except TypeError:
quantity = 0.0
if quantity < 0:
return - quantity
......@@ -543,7 +543,7 @@ class Movement(XMLObject, Amount):
quantity = self.getQuantity()
try:
quantity = float(quantity)
except:
except TypeError:
quantity = 0.0
if quantity < 0:
return 0.0
......@@ -565,7 +565,7 @@ class Movement(XMLObject, Amount):
return 0.0
try:
source_debit = float(source_debit)
except:
except TypeError:
source_debit = 0.0
self.setQuantity(- source_debit)
......@@ -578,7 +578,7 @@ class Movement(XMLObject, Amount):
return 0.0
try:
source_credit = float(source_credit)
except:
except TypeError:
source_credit = 0.0
self.setQuantity(source_credit)
......
......@@ -95,15 +95,11 @@ class Resource(XMLMatrix, CoreResource, Variated):
base_category_list = (base_category_list,)
other_base_category_dict = dict([(i,1) for i in base_category_list])
try:
other_variations = self.searchFolder( \
portal_type=self.getPortalVariationTypeList(),
sort_on=[('title','ascending')])
except:
other_variations = []
other_variations = map(lambda x: x.getObject(), other_variations)
other_variations = filter(lambda x: x is not None, other_variations)
other_variations = [x.getObject() for x in other_variations]
other_variations = [x for x in other_variations if x is not None]
for object in other_variations:
for base_category in object.getVariationBaseCategoryList():
......@@ -263,7 +259,7 @@ class Resource(XMLMatrix, CoreResource, Variated):
def getDefaultDestinationAmountBis(self, unit=None, variation=None, REQUEST=None):
try:
return self.getDestinationReference()
except:
except AttributeError:
return None
# This patch is temporary and allows to circumvent name conflict in ZSQLCatalog process for Coramy
......@@ -272,7 +268,7 @@ class Resource(XMLMatrix, CoreResource, Variated):
def getDefaultSourceAmountBis(self, unit=None, variation=None, REQUEST=None):
try:
return self.getSourceReference()
except:
except AttributeError:
return None
......
......@@ -832,7 +832,7 @@ class ERP5Generator(PortalGenerator):
try:
# Use NuxUserGroups instead of the standard acl_users.
p.manage_addProduct['NuxUserGroups'].addUserFolderWithGroups()
except:
except KeyError:
# No way.
PortalGenerator.setupUserFolder(self, p)
......
......@@ -78,7 +78,7 @@ class InventoryBrain(ZSQLBrain):
try:
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return resource.getQuantityUnit()
except:
except AttributeError:
return ''
......@@ -136,7 +136,7 @@ class InventoryListBrain(ZSQLBrain):
try:
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return resource.getQuantityUnit()
except:
except AttributeError:
return ''
def getListItemUrl(self, cname_id, selection_index, selection_name):
......@@ -189,7 +189,7 @@ class InventoryListBrain(ZSQLBrain):
resource = self.portal_categories.unrestrictedTraverse(self.resource_relative_url)
return '%s/Resource_movementHistoryView?%s&reset=1' % (resource.absolute_url(),
make_query(variation_text=self.variation_text, selection_name=selection_name, selection_index=selection_index))
except:
except (AttributeError, KeyError):
return ''
def getAggregateListText(self):
......
......@@ -114,7 +114,7 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
while o.meta_type == 'ERP5 Category' or o.meta_type == 'CMF Category':
o = o.aq_parent
uid_dict[(int(o.uid), bo_uid, 0)] = 1 # Non strict
except:
except (TypeError, KeyError):
LOG('WARNING: CategoriesTool',0, 'Unable to find uid for %s' % path)
return uid_dict.keys()
......
......@@ -1358,7 +1358,7 @@ class SimulationTool (BaseTool):
# XXX WARNING - ADD PRICED QUANTITY
cell_price = movement.getPrice()
cell_total_price += movement.getNetConvertedTargetQuantity() * cell_price
except:
except TypeError:
cell_total_price = None
for category in movement.getCategoryList():
if category not in cell_category_list:
......
......@@ -154,7 +154,7 @@ class Variated(Base):
"""
try:
resource = self.getDefaultResourceValue()
except:
except AttributeError:
resource = None
if resource is not None:
result = resource.getVariationBaseCategoryList()
......@@ -200,7 +200,7 @@ class Variated(Base):
"""
try:
resource = self.getDefaultResourceValue()
except:
except AttributeError:
resource = None
if resource is not None:
clist = resource.getVariationRangeCategoryItemList(base_category_list =
......@@ -217,7 +217,7 @@ class Variated(Base):
"""
try:
resource = self.getDefaultResourceValue()
except:
except AttributeError:
resource = None
if resource is not None:
clist = resource.getVariationRangeCategoryItemList(base_category_list =
......@@ -234,7 +234,7 @@ class Variated(Base):
"""
try:
resource = self.getDefaultResourceValue()
except:
except AttributeError:
resource = None
if resource is not None:
clist = resource.getVariationRangeCategoryItemList(base_category_list =
......
......@@ -37,6 +37,7 @@ from Products.ERP5Type import PropertySheet
from urllib import quote
from Globals import InitializeClass, PersistentMapping, DTMLFile
from AccessControl import Unauthorized, getSecurityManager, ClassSecurityInfo
from ZODB.POSException import ConflictError
from Products.ERP5Type.Utils import UpperCase
......@@ -85,6 +86,8 @@ def get_value(self, id, **kw):
kw['cell'] = kw['REQUEST']
try:
value = tales_expr.__of__(self)(**kw)
except ConflictError:
pass
except:
# We add this safety exception to make sure we always get
# something reasonable rather than generate plenty of errors
......@@ -117,7 +120,7 @@ def get_value(self, id, **kw):
key = self.id
key = key[3:]
value = object.getProperty(key, d=value)
except:
except KeyError:
value = None
# if normal value is a callable itself, wrap it
......@@ -194,7 +197,7 @@ def add_and_edit(self, id, REQUEST):
return
try:
u = self.DestinationURL()
except:
except AttributeError:
u = REQUEST['URL1']
if REQUEST['submit'] == " Add and Edit ":
u = "%s/%s" % (u, quote(id))
......@@ -419,7 +422,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
for k in self.get_field_ids():
try:
self._delObject(k)
except:
except AttributeError:
pass
self.groups = {}
self.group_list = []
......
......@@ -44,6 +44,7 @@ from Products.ZSQLCatalog.zsqlbrain import ZSQLBrain
from Acquisition import aq_base, aq_inner, aq_parent, aq_self
from zLOG import LOG
from ZODB.POSException import ConflictError
from Globals import InitializeClass, Persistent, Acquisition, get_request
from Products.PythonScripts.Utility import allow_class
......@@ -792,7 +793,7 @@ class ListBoxWidget(Widget.Widget):
# Try to get the method through acquisition
try:
list_method = getattr(here, list_method.method_name)
except:
except (AttributeError, KeyError):
pass
elif list_method in (None, ''): # Use current selection
# Use previously used list method
......@@ -808,7 +809,7 @@ class ListBoxWidget(Widget.Widget):
# Try to get the method through acquisition
try:
count_method = getattr(here, count_method.method_name)
except:
except (AttributeError, KeyError):
count_method = None
else:
# No count method defined means that all objects must be retrieved.
......@@ -829,7 +830,7 @@ class ListBoxWidget(Widget.Widget):
try:
stat_method = getattr(here, stat_method.method_name)
show_stat = 1
except:
except (AttributeError, KeyError):
show_stat = 0
pass
else:
......@@ -889,7 +890,7 @@ class ListBoxWidget(Widget.Widget):
select_expression += stats[index] + '(' + sql + ') AS ' + alias + ','
else:
select_expression += '\'&nbsp;\' AS ' + alias + ','
except:
except KeyError:
select_expression += '\'&nbsp;\' AS ' + alias + ','
index = index + 1
......@@ -906,7 +907,7 @@ class ListBoxWidget(Widget.Widget):
try:
start = REQUEST.get('list_start')
start = int(start)
except:
except (TypeError, KeyError):
start = params.get('list_start',0)
start = int(start)
start = max(start, 0)
......@@ -1124,7 +1125,7 @@ class ListBoxWidget(Widget.Widget):
try:
method_path = getPath(here) + '/' + list_method.method_name
#LOG('ListBox', 0, 'method_path = %s, getPath = %s, list_method.method_name = %s' % (repr(method_path), repr(getPath(here)), repr(list_method.method_name)))
except:
except AttributeError:
method_path = getPath(here) + '/' + list_method.__name__
#LOG('ListBox', 0, 'method_path = %s, getPath = %s, list_method.__name__ = %s' % (repr(method_path), repr(getPath(here)), repr(list_method.__name__)))
# Sometimes the seltion name is a list ??? Why ????
......@@ -1628,6 +1629,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
del kw['closed_summary']
params = dict(kw)
selection.edit(params=params)
except ConflictError:
raise
except:
LOG('ListBox', 0, 'WARNING: Could not call %s with %s: ' % (repr(attribute_value), repr(params)), error=sys.exc_info())
pass
......@@ -1637,7 +1640,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
if real_o is None:
try:
real_o = o.getObject()
except:
except AttributeError:
pass
if real_o is not None:
try:
......@@ -1651,11 +1654,11 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
attribute_original_value = attribute_value
#LOG('Look up accessor %s' % cname_id,0,str(attribute_value))
except:
except AttributeError:
attribute_value = getattr(real_o,property_id)
attribute_original_value = attribute_value
#LOG('Fallback to attribute %s' % cname_id,0,str(attribute_value))
except:
except AttributeError:
attribute_value = 'Can not evaluate attribute: %s' % sql
attribute_original_value = None
else:
......@@ -1669,6 +1672,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
except TypeError:
attribute_value = attribute_value()
attribute_original_value = attribute_value
except ConflictError:
raise
except:
LOG('ListBox', 0, 'Could not evaluate', error=sys.exc_info())
attribute_value = "Could not evaluate"
......@@ -1759,6 +1764,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_body = list_body + \
("<td class=\"%s\" align=\"%s\"><a href=\"%s\">%s</a></td>" %
(td_css, td_align, object_url, attribute_value))
except ConflictError:
raise
except:
LOG('ListBox', 0, 'Could not evaluate url_method %s' % column[1], error=sys.exc_info())
list_body = list_body + \
......@@ -1773,7 +1780,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_body = list_body + \
("<td class=\"%s\" align=\"%s\"><a href=\"%s\">%s</a></td>" %
(td_css, td_align, object_url, attribute_value))
except:
except AttributeError:
list_body = list_body + \
("<td class=\"%s\" align=\"%s\">%s</td>" % (td_css, td_align, attribute_value) )
else:
......@@ -1782,6 +1789,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
list_body = list_body + \
("<td class=\"%s\" align=\"%s\"><a href=\"%s\">%s</a></td>" %
(td_css, td_align, object_url, attribute_value))
except ConflictError:
raise
except:
list_body = list_body + \
("<td class=\"%s\" align=\"%s\">%s</td>" % (td_css, td_align, attribute_value) )
......@@ -1854,6 +1863,8 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
#params['operator'] = stats[n]
#value=value(**params)
value=value(selection=selection)
except ConflictError:
raise
except:
LOG('ListBox', 0, 'WARNING: Could not call %s with %s: ' % (repr(value), repr(params)), error=sys.exc_info())
pass
......@@ -1883,7 +1894,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setReportRoot')">
#if render_format == 'list': current_listboxline.addColumn( column[1] , None)
if render_format == 'list':
current_listboxline.addColumn( column[0] , None)
except:
except KeyError:
list_body += '<td class="Data">&nbsp;</td>'
#if render_format == 'list': current_listboxline.addColumn( column[1] , None)
if render_format == 'list': current_listboxline.addColumn( extended_columns[n][0] , None)
......
......@@ -39,6 +39,7 @@ from urllib import quote
from Globals import InitializeClass, PersistentMapping, DTMLFile, get_request
from AccessControl import Unauthorized, getSecurityManager, ClassSecurityInfo
import urllib2
from ZODB.POSException import ConflictError
from Products.ERP5Type.Utils import UpperCase
......@@ -75,7 +76,7 @@ def add_and_edit(self, id, REQUEST):
return
try:
u = self.DestinationURL()
except:
except AttributeError:
u = REQUEST['URL1']
if REQUEST['submit'] == " Add and Edit ":
u = "%s/%s" % (u, quote(id))
......@@ -230,6 +231,8 @@ if HAS_ZODB_RESOURCE_HANDLER:
if callable(obj):
try:
obj = obj()
except ConflictError:
raise
except:
pass
......@@ -259,6 +262,8 @@ else:
if callable(obj):
try:
obj = obj()
except ConflictError:
raise
except:
pass
......
......@@ -370,7 +370,7 @@ def createLineObject(meta_types,selection,selection_name,field,REQUEST,list_meth
# Try to get the method through acquisition
try:
list_method = getattr(here, list_method.method_name)
except:
except AttributeError:
pass
elif list_method in (None, ''): # Use current selection
list_method = None
......
......@@ -156,7 +156,7 @@ def add_and_edit(self, id, REQUEST):
return
try:
u = self.DestinationURL()
except:
except AttributeError:
u = REQUEST['URL1']
if REQUEST['submit'] == " Add and Edit ":
u = "%s/%s" % (u, quote(id))
......
......@@ -308,10 +308,10 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
try:
current_zoom=self.params['zoom']
if current_zoom != None:
return self.params['zoom']
return current_zoom
else:
return 1
except:
except KeyError:
return 1
security.declarePublic('getReportList')
......
......@@ -399,7 +399,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
if selection is not None:
try:
return selection.stats
except:
except AttributeError:
return stats # That is really bad programming XXX
else:
return stats
......@@ -1095,7 +1095,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
# be sure that method name is correct
try:
method_count = string.atoi(method_count_string)
except:
except TypeError:
return aq_base_name
else:
......@@ -1103,7 +1103,7 @@ class SelectionTool( UniqueObject, SimpleItem ):
# be sure that method name is correct
try:
sub_index = string.atoi(method_count_string_list[1])
except:
except TypeError:
return aq_base_name
else:
sub_index = None
......
......@@ -32,6 +32,7 @@ from Products.ERP5Type import Permissions
from Products.ERP5Type.Utils import convertToUpperCase
from Products.CMFCore.utils import getToolByName
from Acquisition import aq_base, aq_inner, aq_chain, aq_acquire
from ZODB.POSException import ConflictError
import datetime
......@@ -170,11 +171,11 @@ class BaobabConduit(ERP5Conduit):
# Modules below are not always required
# (it depends of the nature of objects you want to synchronize)
try: cash_inventory_module = object.cash_inventory_module
except: cash_inventory_module = None
except KeyError: cash_inventory_module = None
try: bank_account_inventory_module = object.bank_account_inventory_module
except: bank_account_inventory_module = None
except KeyError: bank_account_inventory_module = None
try: currency_cash_module = object.currency_cash_module
except: currency_cash_module = None
except KeyError: currency_cash_module = None
subobject = None
......@@ -190,6 +191,8 @@ class BaobabConduit(ERP5Conduit):
parent_object_path = erp5_site_path + path
try:
parent_object = object.restrictedTraverse(parent_object_path)
except ConflictError:
raise
except:
LOG( 'BaobabConduit:'
, 100
......
......@@ -78,7 +78,7 @@ class Setter(Method):
if file_upload:
try:
o = getattr(instance, self._storage_id)
except:
except AttributeError:
# We create a default type
o = instance.PUT_factory(self._storage_id,
file_upload.headers.get('content-type', None), file_upload )
......
......@@ -39,7 +39,7 @@ def identity(value):
def asFloat(value):
try:
result = float(value)
except:
except TypeError:
result = type_definition['float']['default']
return result
......@@ -49,21 +49,21 @@ def asDate(value):
result = value
else:
result = DateTime(value)
except:
except TypeError:
result = type_definition['date']['default']
return result
def asInt(value):
try:
result = int(value)
except:
except TypeError:
result = type_definition['int']['default']
return result
def asLong(value):
try:
result = long(value)
except:
except TypeError:
result = type_definition['long']['default']
return result
......@@ -73,7 +73,7 @@ def asString(value):
result = ''
else:
result = str(value)
except:
except TypeError:
result = type_definition['string']['default']
return result
......
......@@ -813,6 +813,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
#LOG("Changing attr: ",0, key)
try:
ERP5PropertyManager._setProperty(self, key, value, type=type)
except ConflictError:
raise
except:
# This should be removed if we want strict property checking
setattr(self, key, value)
......@@ -861,6 +863,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
#LOG("Changing attr: ",0, key)
try:
ERP5PropertyManager._setPropValue(self, key, value)
except ConflictError:
raise
except:
# This should be removed if we want strict property checking
setattr(self, key, value)
......@@ -878,6 +882,8 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
method = getattr(self, accessor_name)
try:
return method()
except ConflictError:
raise
except:
return 0
else:
......@@ -916,10 +922,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
Each time attributes of an object are updated, they should
be updated through this generic edit method
"""
try:
categoryIds = self._getCategoryTool().getBaseCategoryIds()
except:
categoryIds = []
id_changed = 0
self._v_modified_property_dict = {}
for key in kw.keys():
......@@ -1520,7 +1523,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
def getIntId(self):
try:
return int(self.getId())
except:
except TypeError:
return None
# Default views
......
......@@ -300,13 +300,13 @@ def ActionProviderBase_extractAction( self, properties, index ):
if type( visible ) is not type( 0 ):
try:
visible = int( visible )
except:
except TypeError:
visible = 0
if type( optional ) is not type( 0 ):
try:
optional = int( optional )
except:
except TypeError:
optional = 0
if type( permissions ) is type( '' ):
......
......@@ -26,6 +26,7 @@ from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
from Globals import PersistentMapping, MessageDialog
from Products.ERP5Type.Utils import get_request
from Products.CMFCore.WorkflowCore import WorkflowException
from zLOG import LOG
import re
......@@ -206,12 +207,12 @@ class CopyContainer:
source_item = '/'.join(copied_item_list[0])
try :
pw.doActionFor(self_base, 'edit_action', wf_id='edit_workflow', comment='Object copied from %s' % source_item)
except :
except WorkflowException:
pass
else :
try :
pw.doActionFor(self_base, 'edit_action', wf_id='edit_workflow', comment='Object copied as %s' % item.getId())
except :
except WorkflowException:
pass
......
......@@ -116,7 +116,7 @@ class FolderMixIn(ExtensionClass.Base):
if id_group is None or id_group=='None':
try:
my_id = int(self.getLastId())
except:
except TypeError:
my_id = 1
while self.hasContent(str(my_id)):
my_id = my_id + 1
......@@ -455,7 +455,7 @@ be a problem)."""
try:
newob = to_class(obase.id)
newob.id = obase.id # This line activates obase.
except:
except AttributeError:
newob = to_class(id)
newob.id = id
keys = obase.__dict__.keys()
......
......@@ -1393,7 +1393,7 @@ def createDefaultAccessors(property_holder, id, prop = None,
default = prop.get('default')
try:
default = default[0]
except:
except TypeError:
default = None
accessor_name = 'get' + UpperCase(id)
base_accessor = List.Getter(accessor_name, id, prop['type'], default = default,
......@@ -2568,7 +2568,7 @@ def assertAttributePortalType(o, attribute_name, portal_type):
if type(portal_type) is type('a'): portal_type = [portal_type]
if getattr(o, attribute_name).portal_type not in portal_type:
o._delObject(attribute_name)
except:
except (KeyError, AttributeError):
LOG("ERPType Warning: assertAttributePortalType",100,str(o.absolute_url()))
#####################################################
......
......@@ -706,6 +706,8 @@ class ZCatalog(Folder, Persistent, Implicit):
try:
obj = self.aq_parent.unrestrictedTraverse(self.getpath(uid, sql_catalog_id=sql_catalog_id))
except ConflictError:
raise
except:
LOG('WARNING: ZSQLCatalog',0,'Could not find object for uid %s' % uid)
obj = None
......@@ -903,7 +905,7 @@ class ZCatalog(Folder, Persistent, Implicit):
except: return result
try: add_result=result.append
except:
except AttributeError:
raise AttributeError, `result`
for id, ob in items:
......@@ -966,8 +968,12 @@ class ZCatalog(Folder, Persistent, Implicit):
script=REQUEST.script
if string.find(path, script) != 0:
path='%s/%s' % (script, path)
try: return REQUEST.resolve_url(path)
except: pass
try:
return REQUEST.resolve_url(path)
except ConflictError:
raise
except:
pass
def resolve_path(self, path):
"""
......@@ -976,8 +982,12 @@ class ZCatalog(Folder, Persistent, Implicit):
style url. If no object is found, None is returned.
No exceptions are raised.
"""
try: return self.unrestrictedTraverse(path)
except: pass
try:
return self.unrestrictedTraverse(path)
except ConflictError:
raise
except:
pass
def manage_normalize_paths(self, REQUEST, sql_catalog_id=None):
"""Ensure that all catalog paths are full physical paths
......
......@@ -15,6 +15,7 @@
import string
import Acquisition
import sys
from ZODB.POSException import ConflictError
from zLOG import LOG
......@@ -64,6 +65,8 @@ class ZSQLBrain(Acquisition.Implicit):
REQUEST = self.REQUEST
obj = self.aq_parent.portal_catalog.resolve_url(self.getPath(), REQUEST)
return obj
except ConflictError:
raise
except:
LOG("ZCatalog WARNING",0,"Could not access object path %s" % self.getPath(), error=sys.exc_info() )
return None
......@@ -86,6 +89,10 @@ class ZSQLBrain(Acquisition.Implicit):
script=REQUEST.script
if string.find(path, script) != 0:
path='%s/%s' % (script, path)
try: return REQUEST.resolve_url(path)
except: pass
try:
return REQUEST.resolve_url(path)
except ConflictError:
raise
except:
pass
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