Skip to content

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

Description

@djay

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions