Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

UW Oshkosh How-To's: How to list all the sites in a Zope

$
0
0
# Script to place in Zope root that lists 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)
   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)
       print "Plone site <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', site.id)
       print "<br>"
    
return printed

This variant lets you filter out sites with IDs that contain ".unused", ".old", ".migrated", ".abandoned".

You'll want to add "activeonly" to the parameters list.  Give that a value of 1 or True so it shows only the active sites, otherwise it will show all the sites.

 

# Script to place in Zope root that lists all the contained Plone sites.

for itemTuple in context.items():
 (item, itemType) = itemTuple
 if str(itemType).startswith('<PloneSite at '):
   site = getattr(context, item)
   id = site.id
   if (activeonly.strip().lower() == "false" or activeonly.strip() == "0") or (activeonly and id.find('.old') == -1 and id.find('.unused') == -1 and id.find('.abandoned') == -1 and id.find('.migrated') == -1):
     print "Plone site <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', id)
     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)
       id = site.id
       if (activeonly.strip().lower() == "false" or activeonly.strip() == "0") or (activeonly and id.find('.old') == -1 and id.find('.unused') == -1 and id.find('.abandoned') == -1 and id.find('.migrated') == -1):
         print "Plone site <a href=\"%s\">%s</a>: " % (site.portal_url()+'/manage_propertiesForm', id)
         print "<br>"
    
return printed

Viewing all articles
Browse latest Browse all 3535

Trending Articles