You are here: Home / Documentation / How To's / How to get a list of the site owners

How to get a list of the site owners

by nguyen — published Apr 09, 2009 11:25 AM, last modified Aug 16, 2016 10:50 AM
.listSiteOwners

You'll want to run the following script in the root of every Zope, then paste all of the resulting "uniqueDict" email address (printed at the bottom of the output) into your mailing list management software. Hopefully that software is smart enough not to send duplicate invitations nor to send invitations to those who are already subscribed.

# Script to place in Zope root that shows email_from_address 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 <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', site.id)
   email = site.email_from_address
   if site.id.endswith('.ignore') or site.id.endswith('.old') or site.id.endswith('.unused') or site.id.endswith('.abandoned') or site.id.endswith('.migrated'):
       print "    ", 'IGNORING', "<br>"   
       continue
   print "    <a href='mailto:%s'>%s</a><br>" % (email, email)
   if email:
       uniqueDict[email] = 1
 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)
       print "Plone site <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', site.id)
       email = site.email_from_address
       if site.id.endswith('.ignore') or site.id.endswith('.old') or site.id.endswith('.unused') or site.id.endswith('.abandoned') or site.id.endswith('.migrated'):
           print "    ", 'IGNORING', "<br>"   
           continue
       print "    <a href='mailto:%s'>%s</a><br>" % (email, email)
       if email:
           uniqueDict[email] = 1
    
print "uniqueDict: %s" % ','.join(uniqueDict.keys())
return printed

A variant that sends out email to the site owner if you click on his/her email address:

# Script to place in Zope root that shows email_from_address 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 <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', site.id)
   email = site.email_from_address
   if site.id.endswith('.ignore') or site.id.endswith('.old') or site.id.endswith('.unused') or site.id.endswith('.abandoned') or site.id.endswith('.migrated'):
       print "    ", 'IGNORING', "<br>"   
       continue
   print "    <a href='mailto:%s'>%s</a><br>" % (email, email)
   if email:
       uniqueDict[email] = 1
 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)
       print "Plone site <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', site.id)
       email = site.email_from_address
       if site.id.endswith('.ignore') or site.id.endswith('.old') or site.id.endswith('.unused') or site.id.endswith('.abandoned') or site.id.endswith('.migrated'):
           print "    ", 'IGNORING', "<br>"   
           continue
       #print "    <a href='mailto:%s'>%s</a><br>" % (email, email)
       emailbody = """%0D
%0D
Hi - your web site uses Plone version 3.0.  I need to upgrade it to Plone 3.2 in the near future.  Here is how I plan to proceed:%0D
%0D
- I will make a copy of your site on the Plone 3.2 server and will give it almost the same URL (instead of "www.uwosh.edu" it will be "plonedev.uwosh.edu")%0D
%0D
- I would give you, say, a week to look over the new site so you can check that it all looks good.%0D
%0D
- At the end of that week or when I have your OK, I will switch the URLs so that your normal URL points to the new Plone 3.2 site.%0D
%0D
- Your old Plone 3.0 site will be archived for a few weeks in case we missed something.%0D
%0D
Does that seem ok with you?%0D
%0D
	%09Kim%0D%0D
"""       
       print "    <a href='mailto:%s?subject=upgrading your Plone web site at &cc=ledwell@uwosh.edu&body=%s'>%s</a><br>" % (email, emailbody, email)
       if email:
           uniqueDict[email] = 1
    
print "uniqueDict: %s" % ','.join(uniqueDict.keys())
return printed
Navigation