finding orphaned Product objects
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@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
Fred Yankowski wrote:
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.
I think my approach would to find all the legal meta_types, and then traverse the whole tree, and see if the products had any of the legal meta types (untested): from cStringIO import StringIO import Products def batch(self): "A batch processor script" out = StringIO() pr = out.write # legal types checker = {} for mt in Products.meta_types: checker[mt] = 1 # Find the objects objects = self.ZopeFind(self, search_sub=1) for path, obj in objects: if not checker.get(obj.meta_type, 0) parent = obj.aq_parent try: pr('Deleting object at: %s of type:\n' % ('/'.join(obj.getPhysicalPath(), obj.meta_type))) parent.manage_delObjects(ids=obj.getId()) except: pr('There was a failure\n') return out.getvalue() regards Max M
Fred Yankowski wrote at 2004-3-9 15:31 -0600:
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.
Delete all (closed) products in "Control_Panel --> Product management", then restart Zope. The still installed products will get recreated. Be careful: instances from no longer installed products may pose significant problems. There is currently a thread describing such problems (a folder can no longer be accessed because it contains such an instance). -- Dieter
On Wed, Mar 10, 2004 at 10:33:23PM +0100, Dieter Maurer wrote:
Delete all (closed) products in "Control_Panel --> Product management", then restart Zope. The still installed products will get recreated.
Interesting idea; I might try that. I sometimes see exception backtraces that refer to old locations of products, where they were when most recently installed (I think) and not under the current $INSTANCE_HOME/Products. I suppose that your procedure would fix that.
Be careful: instances from no longer installed products may pose significant problems.
Yes, but the products that are removed by your procedure would be exactly those that are no longer available on the filesystem. So wouldn't any instances from those products have been broken in the first place, before deleting the products? (Assuming that no product files have changed since the last zope restart). I know that I don't have any broken objects in the zope instance I'm working on. -- Fred Yankowski fred@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
Fred Yankowski wrote at 2004-3-10 16:20 -0600:
...
Be careful: instances from no longer installed products may pose significant problems.
Yes, but the products that are removed by your procedure would be exactly those that are no longer available on the filesystem. So wouldn't any instances from those products have been broken in the first place, before deleting the products?
You are probably right. However, there seem to be two different kinds of brokenness: * Usually, broken objects are represented by a "broken object" * Sometime, they prevent access to the object that contains the broken object. I do not yet understand the difference, although I already had one case of the bad type. Maybe, I will understand it should it happen again... -- Dieter
participants (3)
-
Dieter Maurer -
Fred Yankowski -
Max M