[Zope-CMF] Removing members

Sidnei da Silva sidnei@x3ng.com.br
Fri, 12 Jul 2002 15:26:04 -0300


On Sex 12 Jul 2002 14:57, Pawel Lewicki wrote:
| > maybe if you delete them from the acl_users folder?
|
| The problem is that I succesfully delete it from acl_users. But it still
| remains until I manually call Prune orphaned member records from
| portal_memberdata/Contents
| I am looking for the way to do it from the python script.
|
| Pawel Lewicki

Theres a pruneMemberDataContents() method on MemberDataTool, but it is 
private. This means that you cannot call it with TTW scripts (python scripts, 
dtml-method, dtml-document, zpt....). But using an External Method should 
enable you to call this method. So, lets go to the recipe:

* Create a file named pruneMemberData.py on the 'Extensions' dir of your Zope 
instance.

* On this file, create a method with these contents:

"""
Method to call pruneMemberData via ZMI.
"""
from Products.CMFCore.utils import getToolByName
def pruneMemberData(self):
  mdtool = getToolByName(self, 'portal_memberdata')
  try:
    mdtool.pruneMemberDataContents()
    return '* MemberData for non-existent users on acl_users removed."
  except:
    return '* ERROR: MemberData was not removed."

* Now, go to the ZMI and add an External Method on your CMF Site with this 
configuration:
 
  id: pruneMemberData
  title: 
  module: pruneMemberData
  function: pruneMemberData

* Click save, open the newly added External Method and click the "Test" tab.

* Voila! You are done.

Hope this works, as I havent tested.

-- 
Sidnei da Silva (dreamcatcher) <sidnei@x3ng.com.br>
X3ng Web Technology <http://www.x3ng.com.br>
GNU/Linux user 257852
Debian GNU/Linux 3.0 (Sid) 2.4.18-newpmac ppc

C++ is the best example of second-system effect since OS/360.