Replacing infinite-recursion happy traverse_parent_folders method with one based on aq_chain; evilbungle branch merge.
svn path=/plone.app.discussion/trunk/; revision=30660
This commit is contained in:
parent
60b6196736
commit
78d547daa6
@ -111,36 +111,23 @@ class Conversation(Traversable, Persistent, Explicit):
|
|||||||
if IFolderish.providedBy(aq_inner(self.__parent__)) and not INonStructuralFolder.providedBy(aq_inner(self.__parent__)):
|
if IFolderish.providedBy(aq_inner(self.__parent__)) and not INonStructuralFolder.providedBy(aq_inner(self.__parent__)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Traverse the object tree.
|
def traverse_parents(obj):
|
||||||
def traverse_parent_folder(obj):
|
# Run through the aq_chain of obj and check if discussion is
|
||||||
# Run through the object tree from context,
|
# enabled in a parent folder.
|
||||||
# to the Plone Site Root and look for the first folder object
|
for obj in self.aq_chain:
|
||||||
# that has allow_discussion set to True or False.
|
|
||||||
if not IPloneSiteRoot.providedBy(obj):
|
if not IPloneSiteRoot.providedBy(obj):
|
||||||
if IFolderish.providedBy(obj) and \
|
if IFolderish.providedBy(obj) and \
|
||||||
not INonStructuralFolder.providedBy(obj):
|
not INonStructuralFolder.providedBy(obj):
|
||||||
# If the current object is a Plone folder,
|
allow_discussion_flag = getattr(obj,'allow_discussion',None)
|
||||||
# check if the discussion_allowed flag is set.
|
if allow_discussion_flag is not None:
|
||||||
allow_discussion_flag = getattr(obj, 'allow_discussion', None)
|
return allow_discussion_flag
|
||||||
if allow_discussion_flag == True:
|
return None
|
||||||
return True
|
|
||||||
elif allow_discussion_flag == False:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
# If allow_discussion flag is not set, go on traversing.
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
# If the current object is not a Plone folder,
|
|
||||||
# go on with traversal.
|
|
||||||
foo = traverse_parent_folder(aq_parent(obj))
|
|
||||||
if foo:
|
|
||||||
return True
|
|
||||||
|
|
||||||
obj = aq_parent(self)
|
obj = aq_parent(self)
|
||||||
|
|
||||||
# Check if traversal returned a folder with discussion_allowed set
|
# Check if traversal returned a folder with discussion_allowed set
|
||||||
# to True or False.
|
# to True or False.
|
||||||
folder_allow_discussion = traverse_parent_folder(obj)
|
folder_allow_discussion = traverse_parents(obj)
|
||||||
if folder_allow_discussion == True:
|
if folder_allow_discussion == True:
|
||||||
if not getattr(self, 'allow_discussion', None):
|
if not getattr(self, 'allow_discussion', None):
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user