setMemberProperties method throws an error


Our environment is

Plone 4.3.3 (4308)
CMF 2.2.7
Zope 2.13.22
Python 2.7.6 (default, Jun 2 2016, 08:31:24) [GCC 4.8.4]
PIL 2.3.0 (Pillow)

I am using Plomino with Plone 4.3.3 and I had added a piece of code on a PlominoAgent to change the email address of another user with the system. I have manager permissions on my login but I am still seeing this error

line 42, in agent_append_modify_doc_info
Unauthorized: You are not allowed to access 'setMemberProperties' in this context
Context is

The code I am using is

from Products.CMFCore.utils import getToolByName
membership = getToolByName(context, 'portal_membership')
member = membership.getMemberById(user_id)
Log('Get Member email - ' + str(member.getProperty('email')))
Log('Member object - ' + str(member))

The User ID exists on the system and both log statements returns the current values. Interesting, I always though the second print statement returned "User object" but strangely I see the UserID being returned.

I am not sure what is causing this problem and the code I have used is from Plone's Member Profile documentation. Kinda ran out of ideas too.

Any further guidance would be much appreciated.


Sorry - think I might end up answering my question in short period of time.

The original code in is below

    def setMemberProperties(self, member, REQUEST=None, **properties):
        pas = getToolByName(self, 'acl_users')
        if safe_hasattr(member, 'getId'):
            member = member.getId()
        user = pas.getUserById(member)

So I simply substituted this bit of code now to see whether it works

    user = pas.getUserById(member)

And eureka! that worked. I would still like to understand how to use the setMemberProperties as that's the right way to do it.


Look at the docs instead of guessing API methods and their signatures

Thanks @zopyx. I wasn't rambling nor second guessing API methods. It was from the same documentation link I found the code to try but it came up with the error shown on my first post.

Hence why I wanted to know whether I am doing something silly here to get this error.