Skip to content

Commit

Permalink
do not write on read
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Mar 12, 2014
1 parent 18b3cdb commit c9a3967
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,9 @@ Changelog
4.1.3 (unreleased)
------------------

- Do not write member data on read
[vangheem]

- Allow ``properties`` to be passed to ``PloneUser.setProperties``.
This was previously ignored as ``setProperties`` solely utilised
keyword arguments.
Expand Down
27 changes: 23 additions & 4 deletions Products/PlonePAS/tools/memberdata.py
Expand Up @@ -170,6 +170,20 @@ def searchFulltextForMembers(self, s):
res.append(member)
return res

#### check to see if we can add users. Need to be careful here
#### so we do not write on read
def canAddMemberData(self):
try:
if self.REQUEST.REQUEST_METHOD != 'POST':
return False
if getattr(self, '_p_jar', None) and \
len(self._p_jar._registered_objects) > 0:
# XXX do not write on read
return True
except AttributeError:
pass
return False

#### an exact copy from the base, so that we pick up the new MemberData.
#### wrapUser should have a MemberData factory method to over-ride (or even
#### set at run-time!) so that we don't have to do this.
Expand All @@ -183,10 +197,15 @@ def wrapUser(self, u):
members = self._members
if not id in members:
base = aq_base(self)
members[id] = MemberData(base, id)
# Return a wrapper with self as containment and
# the user as context.
return members[id].__of__(self).__of__(u)
md = MemberData(base, id)
if self.canAddMemberData():
# XXX do not write on read
members[id] = md
return md.__of__(self).__of__(u)
else:
# Return a wrapper with self as containment and
# the user as context.
return members[id].__of__(self).__of__(u)

@postonly
def deleteMemberData(self, member_id, REQUEST=None):
Expand Down

1 comment on commit c9a3967

@mister-roboto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TESTS PASSED
Mr.Roboto url : http://jenkins.plone.org/roboto/get_info?push=6723c9963dd04894bb9e5c80b48e43cb
[SUCCESS] kgs-Products.PlonePAS-plone-4.3-python-2.6 kgs
[SUCCESS] kgs-Products.PlonePAS-plone-4.3-python-2.7 kgs
[SUCCESS] kgs-Products.PlonePAS-plone-5.0-python-2.7 kgs

Please sign in to comment.