You are here: Home / Documentation / How To's / How to list customized views and their owners

How to list customized views and their owners

by nguyen — published Oct 06, 2010 12:50 PM, last modified Aug 16, 2016 10:50 AM
.listCustomizedViews, a script that iterates over all the Plone sites in your Zope

When someone customizes views via ZMI portal_view_customizations, not only does it sometimes make the view's python methods unavailable (ie. methods that have been defined in a .py file associated with the view's .pt page template, and that are in the view's class), it also becomes a problem when the customized view owners no longer have Manager role.

We ran into that when we revoked Manager role from accounts of people no longer working here.  The symptoms showed up as an inability to create new content objects such as News Items on a site; even someone with Manager role would get an "insufficient privileges" error.

This script identifies the customized views and shows their owner.  When you click on the link, it takes you to the ZMI Ownership tab for the customized view, where you can then take ownership of the customized view.

# Script to place in Zope root that lists the customized views and their owners
# in all the contained Plone sites.

outln = []
outln.append("starting...")

def doIt(site):
   outln.append("Plone site '%s':" % site.id)
   customizations = site.portal_view_customizations
   items = customizations.items()
   for i in items:
       s, obj = i
       outln.append("&nbsp;&nbsp;&nbsp;&nbsp; %s &nbsp;&nbsp;&nbsp;&nbsp;<a href='%s'>%s</a>" % (obj.owner_info()['id'], obj.absolute_url()+'/manage_owner', s))


for itemTuple in context.items():
 (item, itemType) = itemTuple
 if str(itemType).startswith('<PloneSite at '):
   site = getattr(context, item)
   doIt(site)
 elif str(itemType).startswith('<Folder at '):
   folder = getattr(context, item)
   for folderItemTuple in folder.items():
     (folderItem, folderItemType) = folderItemTuple
     if str(folderItemType).startswith('<PloneSite at '):
       site = getattr(folder, folderItem)
       doIt(site)
    
outln.append("done")
return '<br>'.join(outln)
Navigation