You are here: Home / Documentation / How To's / How to list the site administrators in your Zope

How to list the site administrators in your Zope

by nguyen — published Feb 24, 2009 03:20 PM, last modified Aug 16, 2016 10:50 AM
a script that shows who is in the Administrators group in each Plone site contained in your Zope

At the root of your Zope, create a Script(Python) object with the  following body.  Give it a name like ".listSiteAdmins" so it'll appear above most other content items.

# Script to place in Zope root that shows who is in the Administrators
# group in all the contained Plone sites.

uniqueDict = {}

for itemTuple in context.items():
 (item, itemType) = itemTuple
 if str(itemType).startswith('<PloneSite at '):
   site = getattr(context, item)
   print "Plone site '%s': " % site.id
   adminMembers = site.portal_groups.getGroupById('Administrators').getAllGroupMembers()
   print "    ", [m.getProperty('email', None) for m in adminMembers], "<br>"
   for m in adminMembers:
       email = m.getProperty('email', None)
       if email:
           uniqueDict[email] = 1
 elif str(itemType).startswith('<Folder at '):
   folder = getattr(context, item)
   print "<h1>%s</h1>" % item
   for folderItemTuple in folder.items():
     (folderItem, folderItemType) = folderItemTuple
     if str(folderItemType).startswith('<PloneSite at '):
       site = getattr(folder, folderItem)
       print "Plone site '<a href='%s/%s/prefs_group_members?groupname=Administrators'>%s</a>': " % (item, site.id, site.id)
       adminMembers = site.portal_groups.getGroupById('Administrators').getAllGroupMembers()
       print "    ", [m.getProperty('email', None) for m in adminMembers], "<br>"
       for m in adminMembers:
           email = m.getProperty('email', None)
           if email:
               uniqueDict[email] = 1
    
print "<br><br>uniqueDict: %s" % ','.join(uniqueDict.keys())
return printed

Navigation