[Zope] finding orphaned Product objects
Fred Yankowski
fred at ontosys.com
Tue Mar 9 16:31:51 EST 2004
I want to clean up a Zope instance to remove some installed products
that are no longer needed or even available in the filesystem any
more. I've got an idea about how to do that and I'm looking for
feedback about any problems or shortcomings.
My first thought was to look at each Product object under
Control_Panel.Products and check to see if its home directory exists.
Those objects do have a 'home' attribute but it seems to be
unreliable; the values often refer to directories that no longer exist
(but did exist at the time the product was installed). Such incorrect
home values sometimes occur for products that do exist under
$INSTANCE_HOME/Products and that I'm still using. I wasn't able to
find any other per-Product attribute with such home-directory
information. No joy there.
What I've got now (see attached script) considers each of the Products
and tries to find an imported Product module by the same name. Any
Products without such a module are either orphans (my term) or are a
product created strictly through the web using ZClasses and the like.
I think. I'm planning to delete the orphaned products from the
Control_Panel/Products folder in the ZMI.
Does this plan make sense?
--
Fred Yankowski fred at ontosys.com tel: +1.630.879.1312
OntoSys, Inc PGP keyID: 7B449345 fax: +1.630.879.1370
www.ontosys.com 38W242 Deerpath Rd, Batavia, IL 60510-9461, USA
-------------- next part --------------
def find_orphan_products(app):
''' Print names of orphaned Products, those that do not have a corresponding module. '''
import Products
product_module_names = dir(Products)
product_objects = app.Control_Panel.Products.objectValues()
product_objects.sort(lambda a,b: cmp(a.id,b.id))
for prod in product_objects:
if not prod.id in product_module_names:
print prod.id
if not hasattr(prod, 'thisIsAnInstalledProduct'):
print " not an installed product"
More information about the Zope
mailing list