def cleanUpSkinsTool(context): skins = getToolByName(context, 'portal_skins') # Remove directory views for directories missing on the filesystem for name in skins.keys(): directory_view = skins.get(name) reg_key = getattr(directory_view, '_dirpath', None) if not reg_key: # not a directory view, but a persistent folder continue try: reg_key = _dirreg.getCurrentKeyFormat(reg_key) _dirreg.getDirectoryInfo(reg_key) except ValueError: skins._delObject(name) transaction.savepoint(optimistic=True) existing = skins.keys() # Remove no longer existing entries from skin selections for layer, paths in skins.selections.items(): new_paths = [] for name in paths.split(','): if name == 'plone_styles': # plone_styles has been moved and renamed new_paths.append('classic_styles') elif name in existing: new_paths.append(name) skins.selections[layer] = ','.join(new_paths)
def setUp(self): from Products.CMFCore.DirectoryView import _dirreg WritableFSDVTest.setUp(self) self._registerDirectory(self) info = _dirreg.getDirectoryInfo(self.ob.fake_skin._dirpath) self.use_dir_mtime = info.use_dir_mtime self.saved_cfg_debug_mode = getConfiguration().debug_mode getConfiguration().debug_mode = True
def setUp(self): from Products.CMFCore.DirectoryView import _dirreg WritableFSDVTest.setUp(self) self._registerDirectory(self) info = _dirreg.getDirectoryInfo(self.ob.fake_skin._dirpath) self.use_dir_mtime = info.use_dir_mtime self.saved_cfg_debug_mode = getConfiguration().debug_mode getConfiguration().debug_mode = True
def cleanUpSkinsTool(context): """Cleanup the portal_skins tool. Initially this was created for Plone 4.0 alpha, but was factored out later. - Remove directory views for directories missing on the filesystem. - Remove invalid skin layers from all skin selections. """ skins = getToolByName(context, 'portal_skins') # Remove directory views for directories missing on the filesystem for name in skins.keys(): directory_view = skins.get(name) reg_key = getattr(directory_view, '_dirpath', None) if not reg_key: # not a directory view, but a persistent folder continue try: # Removed in CMF 2.3 if getattr(_dirreg, 'getCurrentKeyFormat', None): reg_key = _dirreg.getCurrentKeyFormat(reg_key) _dirreg.getDirectoryInfo(reg_key) except ValueError: skins._delObject(name) transaction.savepoint(optimistic=True) existing = skins.keys() # Remove no longer existing entries from skin selections for layer, paths in skins.selections.items(): new_paths = [] for name in paths.split(','): if name in existing: new_paths.append(name) elif '/' in name and testSkinLayer(skins, name): new_paths.append(name) else: logger.info( 'Removed no longer existing path %s ' 'from skin selection %s.', name, layer) skins.selections[layer] = ','.join(new_paths)
def cleanUpSkinsTool(context): """Cleanup the portal_skins tool. Initially this was created for Plone 4.0 alpha, but was factored out later. - Remove directory views for directories missing on the filesystem. - Remove invalid skin layers from all skin selections. """ skins = getToolByName(context, 'portal_skins') # Remove directory views for directories missing on the filesystem for name in skins.keys(): directory_view = skins.get(name) reg_key = getattr(directory_view, '_dirpath', None) if not reg_key: # not a directory view, but a persistent folder continue try: # Removed in CMF 2.3 if getattr(_dirreg, 'getCurrentKeyFormat', None): reg_key = _dirreg.getCurrentKeyFormat(reg_key) _dirreg.getDirectoryInfo(reg_key) except ValueError: skins._delObject(name) transaction.savepoint(optimistic=True) existing = skins.keys() # Remove no longer existing entries from skin selections for layer, paths in skins.selections.items(): new_paths = [] for name in paths.split(','): if name in existing: new_paths.append(name) elif '/' in name and testSkinLayer(skins, name): new_paths.append(name) else: logger.info('Removed no longer existing path %s ' 'from skin selection %s.', name, layer) skins.selections[layer] = ','.join(new_paths)
def _registerDirectory(self, obj=None, ignore=None): from Products.CMFCore.DirectoryView import _dirreg from Products.CMFCore.DirectoryView import createDirectoryView if ignore is None: from Products.CMFCore.DirectoryView import ignore filepath = join(self.tempname, self._skinname) subpath = basename(self.tempname) if subpath != 'tests': # we have a temp dir in tests subpath = 'tests/%s' % subpath reg_key = 'Products.CMFCore:%s/%s' % (subpath, self._skinname) _dirreg.registerDirectoryByKey(filepath, reg_key, ignore=ignore) if obj is not None: ob = obj.ob = DummyFolder() info = _dirreg.getDirectoryInfo(reg_key) for entry in info.getSubdirs(): entry_reg_key = '/'.join((reg_key, entry)) createDirectoryView(ob, entry_reg_key, entry)
def _registerDirectory(self, obj=None, ignore=None): from Products.CMFCore.DirectoryView import _dirreg from Products.CMFCore.DirectoryView import createDirectoryView if ignore is None: from Products.CMFCore.DirectoryView import ignore filepath = join(self.tempname, self._skinname) subpath = basename(self.tempname) if subpath != 'tests': # we have a temp dir in tests subpath = 'tests/%s' % subpath reg_key = 'Products.CMFCore:%s/%s' % (subpath, self._skinname) _dirreg.registerDirectoryByKey(filepath, reg_key, ignore=ignore) if obj is not None: ob = obj.ob = DummyFolder() info = _dirreg.getDirectoryInfo(reg_key) for entry in info.getSubdirs(): entry_reg_key = '/'.join((reg_key, entry)) createDirectoryView(ob, entry_reg_key, entry)
def setUp(self): from Products.CMFCore.DirectoryView import _dirreg WritableFSDVTest.setUp(self) self.saved_cfg_debug_mode = getConfiguration().debug_mode getConfiguration().debug_mode = True # initialise skins self._registerDirectory(self) # add a method to the fake skin folder self._writeFile('test2.py', "return 'test2'") # edit the test1 method self._writeFile('test1.py', "return 'new test1'") # add a new folder mkdir(join(self.skin_path_name, 'test3')) info = _dirreg.getDirectoryInfo(self.ob.fake_skin._dirpath) info.reload() self.use_dir_mtime = info.use_dir_mtime
def setUp(self): from Products.CMFCore.DirectoryView import _dirreg WritableFSDVTest.setUp(self) self.saved_cfg_debug_mode = getConfiguration().debug_mode getConfiguration().debug_mode = True # initialise skins self._registerDirectory(self) # add a method to the fake skin folder self._writeFile('test2.py', "return 'test2'") # edit the test1 method self._writeFile('test1.py', "return 'new test1'") # add a new folder mkdir(join(self.skin_path_name, 'test3')) info = _dirreg.getDirectoryInfo(self.ob.fake_skin._dirpath) info.reload() self.use_dir_mtime = info.use_dir_mtime
def setUp(self): from Products.CMFCore.DirectoryView import _dirreg WritableFSDVTest.setUp(self) self.test1path = join(self.skin_path_name, 'test1.py') self.test2path = join(self.skin_path_name, 'test2.py') self.test3path = join(self.skin_path_name, 'test3') # initialise skins self._registerDirectory(self) # add a method to the fake skin folder self._writeFile(self.test2path, "return 'test2'") # edit the test1 method self._writeFile(self.test1path, "return 'new test1'") # add a new folder mkdir(self.test3path) info = _dirreg.getDirectoryInfo(self.ob.fake_skin._dirpath) info.reload() self.use_dir_mtime = info.use_dir_mtime
def setUp( self ): from Products.CMFCore.DirectoryView import _dirreg WritableFSDVTest.setUp(self) self.test1path = join(self.skin_path_name,'test1.py') self.test2path = join(self.skin_path_name,'test2.py') self.test3path = join(self.skin_path_name,'test3') # initialise skins self._registerDirectory(self) # add a method to the fake skin folder self._writeFile(self.test2path, "return 'test2'") # edit the test1 method self._writeFile(self.test1path, "return 'new test1'") # add a new folder mkdir(self.test3path) info = _dirreg.getDirectoryInfo(self.ob.fake_skin._dirpath) info.reload() self.use_dir_mtime = info.use_dir_mtime