Skip to content

Commit

Permalink
Merge pull request #20 from plone/fix_cmfplone_2874
Browse files Browse the repository at this point in the history
Fix cmfplone 2874
  • Loading branch information
pbauer authored Jun 27, 2019
2 parents c14c984 + 97e27a8 commit 96aa515
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
17 changes: 15 additions & 2 deletions Products/CMFDynamicViewFTI/browserdefault.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class BrowserDefaultMixin(Base):
'sharing': 'folder_localrole_form',
'gethtml': '',
'mkdir': '',
}
}

default_view = "base_view"
suppl_views = ()
Expand All @@ -72,7 +72,19 @@ def __call__(self):
Resolve and return the selected view template applied to the object.
This should not consider the default page.
"""
template = self.unrestrictedTraverse(self.getLayout())
layout = self.getLayout()
if layout is None:
# here we would run in a infinite recursion, because
# self.unrestrictedTraverse(None) will always return
# self and then it calls itself again
# since this may lead to a stack overflow crashing the whole
# interpreter it is important to catch this beforehand.
raise ValueError(
"No layout found. "
"This may happen b/c nothing was set. "
"Hint: If no FTI was found this happens as well."
)
template = self.unrestrictedTraverse(layout)
return template()

@security.protected(View)
Expand Down Expand Up @@ -226,6 +238,7 @@ def getAvailableLayouts(self):
result.append((mid, title))
return result


InitializeClass(BrowserDefaultMixin)


Expand Down
5 changes: 3 additions & 2 deletions Products/CMFDynamicViewFTI/fti.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def om_has_key(context, key):
return True
return False


fti_meta_type = 'Factory-based Type Information with dynamic views'


Expand Down Expand Up @@ -206,8 +207,7 @@ def defaultView(self, context):
fallback = self.default_view_fallback
return self.getViewMethod(context, check_exists=fallback)

security.declarePublic('queryMethodID')

@security.public
def queryMethodID(self, alias, default=None, context=None):
# Query method ID by alias.

Expand Down Expand Up @@ -244,4 +244,5 @@ def queryMethodID(self, alias, default=None, context=None):

return methodTarget


InitializeClass(DynamicViewTypeInformation)
4 changes: 4 additions & 0 deletions news/20.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fixes plone/Products.CMFPlone#2874
``Fatal crash: Fatal Python error: Cannot recover from stack overflow``
Which crashes the interpreter.
[jensens]

0 comments on commit 96aa515

Please sign in to comment.