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
Avoid write-on-read when initializing MemberAdapter #28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs additional tests / assertions in unit tests for MemberAdapter.__init__
/ MemberAdapter.notifiyModified
.
@tseaver tests added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The not defined id
should be fixed. Strange that it apparently works. I wonder if the tests do not actually run that code.
Products/CMFCore/MemberDataTool.py
Outdated
|
||
@security.private | ||
def notifyModified(self): | ||
# Links self to parent for full persistence. | ||
self._tool._members[id] = self._md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
is not defined here. It triggers no warnings because id
is a builtin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/id/self._user.getId()/
.
Good catch, @mauritsvanrees. That made me look at what registerMemberData does and realize that even if the broken line I added did what I intended, it would be redundant. |
This avoids writing a MemberData object to the database when MemberAdapter is being looked up for reads only. (The change is needed to avoid triggering CSRF protection errors in Plone tests.)