def getStorageStrategy(self): """Returns the storage strategy""" global _strategy_map portal = getToolByName(self, "portal_url").getPortalObject() portal_path = "/".join(portal.getPhysicalPath()) strategy_class = _strategy_map[ZCONFIG.storageStrategyForSite(portal_path)] return strategy_class(ZCONFIG.storagePathForSite(portal_path), ZCONFIG.backupPathForSite(portal_path))
def globalConfigInfo(self): """A TALES friendly configuration info mapping for global configuration""" return { "config_file": CONFIG_FILE, "strategy": ZCONFIG.storageStrategyForSite("/"), "storage_path": ZCONFIG.storagePathForSite("/"), "backup_path": ZCONFIG.backupPathForSite("/"), }
def testDefaultConfig(self): from Products.FileSystemStorage.config import ZCONFIG self.assertEqual(ZCONFIG.storagePathForSite('/any/site'), os.path.normpath(os.path.expandvars('$INSTANCE_HOME/var/fss_storage'))) self.assertEqual(ZCONFIG.backupPathForSite('/any/site'), os.path.normpath(os.path.expandvars('$INSTANCE_HOME/var/fss_backup'))) self.assertEqual(ZCONFIG.storageStrategyForSite('/any/site'), 'flat') self.assertEqual(len(ZCONFIG.sites), 0) return
def siteConfigInfo(self): """A TALES friendly configuration info mapping for this Plone site""" portal = getToolByName(self, "portal_url").getPortalObject() portal_path = "/".join(portal.getPhysicalPath()) return { "config_file": CONFIG_FILE, "strategy": ZCONFIG.storageStrategyForSite(portal_path), "storage_path": ZCONFIG.storagePathForSite(portal_path), "backup_path": ZCONFIG.backupPathForSite(portal_path), }