Commit 59b3273a authored by Vincent Pelletier's avatar Vincent Pelletier

Do not use "getattr" to guess the folder type:

 - Object is wrapped in acquisition, so we can get attributes from its containers
 - Classes implemeting folder-ish objects *do* define those attributes with varying values (empty tuple on OFS.Folder, None on BTreeFolder, etc).
So the attribute presence must be grabbed from instance properties *only*.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16607 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d6d7c5f6
...@@ -375,10 +375,7 @@ class CMFBTreeFolderHandler(FolderHandler): ...@@ -375,10 +375,7 @@ class CMFBTreeFolderHandler(FolderHandler):
return getattr(CMFBTreeFolder, id) return getattr(CMFBTreeFolder, id)
def isApplicable(self, folder): def isApplicable(self, folder):
result = False return '_tree' in getattr(folder, '__dict__', tuple())
if getattr(folder, '_tree', None) is not None:
result = True
return result
class CMFHBTreeFolderHandler(FolderHandler): class CMFHBTreeFolderHandler(FolderHandler):
...@@ -389,10 +386,7 @@ class CMFHBTreeFolderHandler(FolderHandler): ...@@ -389,10 +386,7 @@ class CMFHBTreeFolderHandler(FolderHandler):
return getattr(CMFHBTreeFolder, id) return getattr(CMFHBTreeFolder, id)
def isApplicable(self, folder): def isApplicable(self, folder):
result = False return '_htree' in getattr(folder, '__dict__', tuple())
if getattr(folder, '_htree', None) is not None:
result = True
return result
class OFSFolderHandler(FolderHandler): class OFSFolderHandler(FolderHandler):
...@@ -403,10 +397,7 @@ class OFSFolderHandler(FolderHandler): ...@@ -403,10 +397,7 @@ class OFSFolderHandler(FolderHandler):
return getattr(OFSFolder, id) return getattr(OFSFolder, id)
def isApplicable(self, folder): def isApplicable(self, folder):
result = False return '_objects' in getattr(folder, '__dict__', tuple())
if getattr(folder, '_objects', None) is not None:
result = True
return result
global folder_handler_dict global folder_handler_dict
folder_handler_dict = {} folder_handler_dict = {}
......
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