Continuing the discussion from Implementing a paid content subscription model on a Plone site:
I have found an issue in the site we implemented the subscription model:
currently the site has around 800 users that have been created using the following code:
def create_subscriber(self, code, email, group): api.user.create(email=email, username=email, properties=dict(code=code)) api.user.revoke_roles(email, roles=['Member']) api.group.add_user(groupname=group, username=email)
the problem arises when I try to delete one of the users:
def remove_subscriber(self, email): with api.env.adopt_roles(['Manager']): api.user.delete(username=email)
as it takes a lot of memory and the instance is restarted by memmon.
is this normal, or is a bug?
checking the code in the membership tool, I see the following things are done:
- delete members in
- delete member data in
- delete members' home folders including all content items
- delete members' local roles
one of this parts is consuming a lot of memory but I have no idea which one.
I think I don't need steps 3 and 4; may I write my own method and skip them to avoid issues with memory consumption?
def remove_subscriber(self, email): membership_tool = api.portal.get_tool('portal_membership') with api.env.adopt_roles(['Manager']): membership_tool.deleteMembers([email], delete_memberareas=False, delete_localroles=False):