def removeBrokenCacheFu(context): portal = getToolByName(context, 'portal_url').getPortalObject() cpm = getattr(portal, 'caching_policy_manager', None) if cpm and cpm.getId() == 'broken': # If we detect a broken CacheFu install, remove it CACHEFU_IDS = [ 'CacheSetup_OFSCache', 'CacheSetup_PageCache', 'caching_policy_manager', 'HTTPCache', 'portal_cache_settings', 'portal_squid', ] cpm = aq_base(cpm) for i in CACHEFU_IDS: portal._delOb(i) objects = portal._objects portal._objects = tuple( [i for i in objects if getattr(portal, i['id'], None)]) sm = getSiteManager(context=portal) sm.unregisterUtility(component=cpm, provided=ICachingPolicyManager) del cpm transaction.savepoint(optimistic=True) manage_addCachingPolicyManager(portal) addCacheHandlers(portal) addCacheForResourceRegistry(portal) logger.info('Removed CacheSetup tools.')
def remove_cachefu(self): """Remove cache fu (done often too late in plonemigration)""" alphas.removeBrokenCacheFu(self.context) knowns = [ self.path + '/portal_cache_settings', self.path + '/portal_squid', self.path + '/CacheSetup_PageCache', self.path + '/caching_policy_manager', self.path + '/HTTPCache', self.path + '/CacheSetup_OFSCache', self.path + '/CacheSetup_ResourceRegistryCache', ] upgrades.commit(self.context) not_deleted = [] for path in knowns: if (not self.delete_path(path) and (not path in not_deleted)): not_deleted.append(path) manage_addCachingPolicyManager(self.context) addCacheHandlers(self.context) addCacheForResourceRegistry(self.context)