Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make finalizeSchema more robust by not handling behavior schema classes. #55

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions news/186.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Make finalizeSchema more robust by not handling behavior schema classes.
Backported from version 2.0.
[maurits]
24 changes: 22 additions & 2 deletions plone/supermodel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,28 @@ def finalizeSchemas(parent=Schema):
)

def walk(schema):
yield schema
for child in schema.dependents.keys():
# When we have behaviors on the Plone site root we got some schemas that
# are not SchemaClasses. Same is true on Plone 5.2 if we use a backported
# fix for plone.dexterity to use 'Provides' instead of 'Implements', which
# should fix a memory leak:
# https://github.com/plone/plone.dexterity/pull/189
# If we yield such a schema, then 'sorted(schemas)' below will fail on
# Python 3 with: TypeError: '<' not supported between instances of
# 'Provides' and 'InterfaceClass'.
if isinstance(schema, SchemaClass):
yield schema

# This try..except is to handle AttributeError:
# 'VerifyingAdapterLookup' object has no attribute 'dependents'.
# afaik this happens in tests only.
# We have issue https://github.com/plone/plone.supermodel/issues/14
# to find out why this is happening in the first place.
try:
children = schema.dependents.keys()
except AttributeError:
children = ()

for child in children:
for s in walk(child):
yield s

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()

version = '1.6.6.dev0'
version = '1.7.0.dev0'

long_description = (
read('README.rst') + '\n' +
Expand Down