--- a/src/pyams_utils/inherit.py Wed Jun 12 20:06:45 2019 +0200
+++ b/src/pyams_utils/inherit.py Fri Jun 14 12:41:06 2019 +0200
@@ -10,18 +10,20 @@
# FOR A PARTICULAR PURPOSE.
#
+"""PyAMS_utils.inherit module
+
+This module is used to manage a generic inheritance between a content and
+it's parent container. It also defines a custom InheritedFieldProperty which
+allows to automatically manage inherited properties.
+"""
+
__docformat__ = 'restructuredtext'
-
-# import standard library
-
-from zope.interface import implementer, Interface
+from zope.interface import Interface, implementer
from zope.location import Location
from zope.schema.fieldproperty import FieldProperty
-# import interfaces
from pyams_utils.interfaces.inherit import IInheritInfo
-# import packages
from pyams_utils.traversing import get_parent
from pyams_utils.zodb import volatile_property
@@ -37,32 +39,39 @@
@volatile_property
def parent(self):
+ """Get current parent"""
return get_parent(self.__parent__, self.target_interface, allow_context=False)
@property
def can_inherit(self):
+ """Check if inheritance is possible"""
return self.target_interface.providedBy(self.parent)
@property
def inherit(self):
+ """Check if inheritance is possible and activated"""
return self._inherit if self.can_inherit else False
@inherit.setter
def inherit(self, value):
+ """Activate inheritance"""
if self.can_inherit:
self._inherit = value
del self.parent
@property
def no_inherit(self):
+ """Inverted boolean value to check if inheritance is possible and activated"""
return not bool(self.inherit)
@no_inherit.setter
def no_inherit(self, value):
+ """Inverted inheritance setter"""
self.inherit = not bool(value)
@property
def inherit_from(self):
+ """Get current parent from which we inherit"""
if not self.inherit:
return self
parent = self.parent