You are here: Home / Documentation / How To's / A script that lists which sites have the SiteOwner role

A script that lists which sites have the SiteOwner role

by nguyen — published Dec 11, 2010 10:48 AM, last modified Aug 16, 2016 10:49 AM
a Script (Python) called .listSiteOwnerRole
# Script to place in Zope root that lists which sites have SiteOwner role

uniqueDict = {}

for itemTuple in context.items():
 (item, itemType) = itemTuple
 if str(itemType).startswith('<PloneSite at '):
   site = getattr(context, item)
   if len(site.acl_users.portal_role_manager.enumerateRoles('SiteOwner')) == 1:
       hasSiteOwnerRole = 'yes'
   else:
       hasSiteOwnerRole = 'no'
   print "Plone site <a href=\"%s\">%s</a>: %s" % (site.portal_url()+'/portal_quickinstaller/manage_workspace', site.id, hasSiteOwnerRole)
   print "<br>"
 elif str(itemType).startswith('<Folder at '):
   folder = getattr(context, item)
   print "<h1><a href='%s/manage_main' target='_blank_'>%s</a></h1>" % (folder.absolute_url(), item)
   for folderItemTuple in folder.items():
     (folderItem, folderItemType) = folderItemTuple
     if str(folderItemType).startswith('<PloneSite at '):
       site = getattr(folder, folderItem)
       if len(site.acl_users.portal_role_manager.enumerateRoles('SiteOwner')) == 1:
           hasSiteOwnerRole = 'yes'
       else:
           hasSiteOwnerRole = 'no'
       print "Plone site <a href=\"%s\">%s</a>: %s" % (site.portal_url()+'/portal_quickinstaller/manage_workspace', site.id, hasSiteOwnerRole)
       print "<br>"
    
return printed
Navigation