Directory: Exclude all property names from the wtforms setattr loop#2499
Conversation
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
…y-properties-from-wtforms-setattr-loop
There was a problem hiding this comment.
Pull request overview
Fixes an AttributeError that occurred when a directory structure defined a field whose normalized id collided with a Python property defined on DirectoryEntry (e.g. text, values, external_link). Previously, only SQLAlchemy InstrumentedAttributes were excluded from the wtforms populate_obj setattr loop; properties (often read-only) were not, leading to errors when wtforms tried to assign to them.
Changes:
- Include
propertyin addition toInstrumentedAttributewhen computing theexcludeset inDirectoryEntryForm.populate_obj. - Add a regression test covering field names that collide with
DirectoryEntryproperties.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/onegov/directory/models/directory.py | Also exclude property attributes from wtforms populate_obj to avoid setting read-only properties. |
| tests/onegov/directory/test_orm.py | New regression test verifying directory fields named after DirectoryEntry properties work end-to-end. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Directory: Exclude all property names from the wtforms
setattrloopTYPE: Bugfix
LINK: ogc-3195