Commit ea134d35 authored by Jérome Perrin's avatar Jérome Perrin

use named Exceptions in except:


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3974 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6ed7bc7
...@@ -253,7 +253,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -253,7 +253,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
return base_category return base_category
try: try:
return relative_url.split('/')[0] return relative_url.split('/')[0]
except: except KeyError :
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryUid') security.declareProtected(Permissions.AccessContentsInformation, 'getBaseCategoryUid')
...@@ -265,7 +265,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -265,7 +265,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
try: try:
return self.getCategoryValue(self.getBaseCategoryId(relative_url, return self.getCategoryValue(self.getBaseCategoryId(relative_url,
base_category = base_category)).uid base_category = base_category)).uid
except: except (AttributeError, KeyError):
return None return None
security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryParentUidList') security.declareProtected(Permissions.AccessContentsInformation, 'getCategoryParentUidList')
...@@ -298,7 +298,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -298,7 +298,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
while o.meta_type == 'CMF Category': while o.meta_type == 'CMF Category':
o = o.aq_parent o = o.aq_parent
uid_dict[(int(o.uid), bo_uid, 0)] = 1 # Non Strict Membership uid_dict[(int(o.uid), bo_uid, 0)] = 1 # Non Strict Membership
except: except (KeyError, AttributeError):
LOG('WARNING: CategoriesTool',0, 'Unable to find uid for %s' % path) LOG('WARNING: CategoriesTool',0, 'Unable to find uid for %s' % path)
return uid_dict.keys() return uid_dict.keys()
...@@ -540,7 +540,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -540,7 +540,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
membership += [path] membership += [path]
else: else:
membership += [path[len(category)+1:]] membership += [path[len(category)+1:]]
except: except (KeyError, ):
LOG('WARNING: CategoriesTool',0, 'Unable to find object for path %s' % path) LOG('WARNING: CategoriesTool',0, 'Unable to find object for path %s' % path)
# We must include parent if specified explicitely # We must include parent if specified explicitely
if 'parent' in category_list: if 'parent' in category_list:
...@@ -604,7 +604,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -604,7 +604,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
for spec_type in spec: for spec_type in spec:
if spec_type == my_type: if spec_type == my_type:
keep_it = 0 keep_it = 0
except: except (KeyError, AttributeError):
keep_it = 0 keep_it = 0
if keep_it: if keep_it:
new_category_list += [path] new_category_list += [path]
...@@ -1340,7 +1340,7 @@ class CategoryTool( UniqueObject, Folder, Base ): ...@@ -1340,7 +1340,7 @@ class CategoryTool( UniqueObject, Folder, Base ):
obj = self.portal_catalog.resolve_url(url, REQUEST) obj = self.portal_catalog.resolve_url(url, REQUEST)
#LOG('Obj type', 0, str(obj.getUid())) #LOG('Obj type', 0, str(obj.getUid()))
return obj return obj
except: except (KeyError, AttributeError) :
LOG("CMFCategory WARNING",0,"Could not access object relative_url %s" % relative_url ) LOG("CMFCategory WARNING",0,"Could not access object relative_url %s" % relative_url )
return None return None
......
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