def _on_save(self, data): """ Deleting the gray-scale converted resources from the filesystem cache """ messages = IStatusMessage(self.request) if data.get("delete_cached_resources"): site = getSite() try: path = str("/++%s++%s" % (TYPE, THEME)) location = site.restrictedTraverse(path).directory except AttributeError, e: log.info("Unable to remove files for: %s due to error: %s" % (path, e)) message = _(u"Couldn't remove files from %s" % path) messages.addStatusMessage(message, type="error") return try: log.info("Removing cached gray-scale files from: %s" % location) for filename in os.listdir(location): file_path = os.path.join(location, filename) if os.path.isfile(file_path): os.unlink(file_path) else: shutil.rmtree(file_path) except OSError, e: log.info("Unable to remove files from: %s, error: %s" % (location, e)) message = _(u"Couldn't remove files from %s" % location) messages.addStatusMessage(message, type="error")
Deleting the gray-scale converted resources from the filesystem cache """ messages = IStatusMessage(self.request) if data.get("delete_cached_resources"): site = getSite() try: path = str("/++%s++%s" % (TYPE, THEME)) location = site.restrictedTraverse(path).directory except AttributeError, e: log.info("Unable to remove files for: %s due to error: %s" % (path, e)) message = _(u"Couldn't remove files from %s" % path) messages.addStatusMessage(message, type="error") return try: log.info("Removing cached gray-scale files from: %s" % location) for filename in os.listdir(location): file_path = os.path.join(location, filename) if os.path.isfile(file_path): os.unlink(file_path) else: shutil.rmtree(file_path) except OSError, e: log.info("Unable to remove files from: %s, error: %s" % (location, e)) message = _(u"Couldn't remove files from %s" % location) messages.addStatusMessage(message, type="error") else: message = _(u"Files from path %s have been removed." % location) messages.addStatusMessage(message, type="info")
Deleting the gray-scale converted resources from the filesystem cache """ messages = IStatusMessage(self.request) if data.get('delete_cached_resources'): site = getSite() try: path = str('/++%s++%s' % (TYPE, THEME)) location = site.restrictedTraverse(path).directory except AttributeError, e: log.info('Unable to remove files for: %s due to: AttributeError: %s' % (path, e)) message = _(u"Couldn't remove files from %s" % path) messages.addStatusMessage(message, type='error') return try: log.info('Removing cached gray-scale files from: %s' % location) for filename in os.listdir(location): file_path = os.path.join(location, filename) if os.path.isfile(file_path): os.unlink(file_path) else: shutil.rmtree(file_path) except OSError, e: log.info('Unable to remove files from: %s due to error: %s' % (location, e)) message = _(u"Couldn't remove files from %s" % location) messages.addStatusMessage(message, type='error') else: message = _(u'Files from path %s have been successfully removed.' % location) messages.addStatusMessage(message, type='info')