Commit c5cd1820 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5.Tool.CategoryTool, Folder: Resolve multi-inheritance from CopyContainer

These two classes inherits from two classes implementing CopyContainer API:
- ours, via low-priority bases
- another one, via higher-priority bases, because these classes need
  some non-ERP5 methods to override ERP5 methods.
So after defining these classes, resolve inheritance priority by binding
all CopyContainer methods provided by their ERP5 base class, overriding
the ones provided by their non-ERP5 bases while still allowing their ERP5
base class to override the CopyContainer method.
parent 564cca95
......@@ -44,7 +44,7 @@ from Products.ERP5Type.dynamic import portal_type_class
from zLOG import LOG
class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
class CategoryTool(CMFCategoryTool, BaseTool):
"""
The CategoryTool object is the placeholder for all methods
and algorithms related to categories and relations in ERP5.
......@@ -152,4 +152,18 @@ class CategoryTool(CopyContainer, CMFCategoryTool, BaseTool):
self.updateRelatedContent(o, previous_o_category_url,
new_o_category_url)
# CMFCategoryTool inherits indirectly from a different CopyContainer which
# lacks our customisations.
# Resolve all inheritence conflicts between CopyContainer (which CategoryTool
# inherits from via BaseTool) and CMFCategoryTool in favour of the property
# from BaseTool (so it may override CopyContainer).
for CopyContainer_property_id in CopyContainer.__dict__:
if CopyContainer_property_id in CategoryTool.__dict__:
continue
try:
BaseTool_property = getattr(BaseTool, CopyContainer_property_id)
except AttributeError:
continue
setattr(CategoryTool, CopyContainer_property_id, BaseTool_property)
InitializeClass( CategoryTool )
......@@ -588,7 +588,7 @@ _HANDLER_LIST = (
# Bad value, accidentally put everywhere long ago
_BROKEN_BTREE_HANDLER = 'CMFBTreeFolderHandler'
class Folder(CopyContainer, OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
class Folder(OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
"""
A Folder is a subclass of Base but not of XMLObject.
Folders are not considered as documents and are therefore
......@@ -1036,9 +1036,6 @@ class Folder(CopyContainer, OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, F
return id
return self.generateNewId()
#security.declareProtected( Permissions.DeletePortalContent, 'manage_delObjects' )
#manage_delObjects = CopyContainer.manage_delObjects
# Implementation
hasContent = hasObject
......@@ -1643,3 +1640,17 @@ for source_klass, destination_klass in \
# Zope 2.7 required to have methodId__roles__ defined
# to know the security ot the method
setattr(destination_klass, method_id+'__roles__', None)
# Some of Folder base inherits indirectly from a different CopyContainer which
# lacks our customisations.
# Resolve all inheritence conflicts between CopyContainer (which Folder
# inherits from via Base) and those bases in favour of the property
# from Base (so it may override CopyContainer).
for CopyContainer_property_id in CopyContainer.__dict__:
if CopyContainer_property_id in Folder.__dict__:
continue
try:
Base_property = getattr(Base, CopyContainer_property_id)
except AttributeError:
continue
setattr(Folder, CopyContainer_property_id, Base_property)
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