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

schema validation can lead to unexpected consequences if an object uses property decorators #127

Open
djay opened this issue Nov 26, 2024 · 0 comments

Comments

@djay
Copy link

djay commented Nov 26, 2024

BUG/PROBLEM REPORT / FEATURE REQUEST

What I did:

Plone has a objects with a schema where the data property is loaded using a decorator which loads the data into memory on first access.
When validating this schema zope is just trying to check if such a property exists but by using getattr it will inadvertently load a large file into memory.

This is a PR to try and avoid this issue - plone/plone.namedfile#166

What I expect to happen:

Check if the the property is really a decorator first so it can be avoided being accessed unless really needed.
Maybe something like https://stackoverflow.com/questions/16169948/check-if-something-is-an-attribute-or-decorator-in-python ?

What actually happened:

getattr is used and the decorator will load all the data into memory even though the schema as not constraints on the contents of the property.

What version of Python and Zope/Addons I am using:

python 3.10, zope.schema 7.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant