def purgeTranslationsOnModified(object, event): """ When the canonical is purged, also purge the translations. This is for content with language independent fields. """ if isPurged(object) and object.isCanonical(): translations = object.getTranslations(include_canonical=False) for translation, state in translations.values(): notify(Purge(translation))
def test_no_portal_type(self): provideUtility(Registry(), IRegistry) registry = getUtility(IRegistry) registry.registerInterface(IPloneCacheSettings) ploneSettings = registry.forInterface(IPloneCacheSettings) ploneSettings.purgedContentTypes = ('testtype',) content = DummyNotContent() self.assertEqual(False, isPurged(content))
def test_not_listed(self): provideUtility(Registry(), IRegistry) registry = getUtility(IRegistry) registry.registerInterface(IPloneCacheSettings) ploneSettings = registry.forInterface(IPloneCacheSettings) ploneSettings.purgedContentTypes = ('File', 'Image',) content = DummyContent() self.assertEqual(False, isPurged(content))
def test_no_portal_type(self): provideUtility(Registry(), IRegistry) registry = getUtility(IRegistry) registry.registerInterface(IPloneCacheSettings) ploneSettings = registry.forInterface(IPloneCacheSettings) ploneSettings.purgedContentTypes = ('testtype', ) content = DummyNotContent() self.assertEqual(False, isPurged(content))
def test_listed(self): provideUtility(Registry(), IRegistry) registry = getUtility(IRegistry) registry.registerInterface(IPloneCacheSettings) ploneSettings = registry.forInterface(IPloneCacheSettings) ploneSettings.purgedContentTypes = ('File', 'Image', 'testtype',) content = DummyContent() self.assertTrue(isPurged(content))
def test_listed(self): provideUtility(Registry(), IRegistry) registry = getUtility(IRegistry) registry.registerInterface(IPloneCacheSettings) ploneSettings = registry.forInterface(IPloneCacheSettings) ploneSettings.purgedContentTypes = ("File", "Image", "testtype") content = DummyContent() self.assertEquals(True, isPurged(content))
def purgeOnMovedOrRemoved(object, event): request = getRequest() confirmed_delete = ('delete_confirmation' in request.URL and request.REQUEST_METHOD == 'POST' and 'form.submitted' in request.form) if IObjectRemovedEvent.providedBy(event) and not confirmed_delete: # ignore extra delete events return # Don't purge when added if IObjectAddedEvent.providedBy(event): return if isPurged(object) and 'portal_factory' not in request.URL: notify(Purge(object)) parent = object.getParentNode() if parent: notify(Purge(parent))
def purgeOnMovedOrRemoved(object, event): # Don't purge when added if event.oldName is not None and event.oldParent is not None: if isPurged(object): notify(Purge(object))
def purgeOnModified(object, event): if isPurged(object): notify(Purge(object))
def test_no_settings(self): provideUtility(Registry(), IRegistry) content = DummyContent() self.assertEqual(False, isPurged(content))
def test_no_registry(self): content = DummyContent() self.assertEqual(False, isPurged(content))
def purgeOnWorkflowTransition(object, event): if isPurged(object): notify(Purge(object))
def purge(obj): """ Purge object """ if isPurged(obj): notify(Purge(obj))