diff --git a/CHANGES.rst b/CHANGES.rst index 958abf3..b38b26f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,7 +17,7 @@ Bug fixes: - Set default purger backlog size to 0 (infinity) in order to fully invalidate Varnish cache [avoinea refs #11] -- Tests are Python 3 compatible +- Tests and Code are Python 3 compatible [pbauer, ale-rt, jensens] diff --git a/plone/cachepurging/browser.py b/plone/cachepurging/browser.py index efb4c40..8a0809d 100644 --- a/plone/cachepurging/browser.py +++ b/plone/cachepurging/browser.py @@ -10,6 +10,10 @@ from zope.component import getUtility from zope.event import notify +RESULT_TPL = ( + "Purged: {url}, Status: {status}, X-Cache: {xcache}, Error: {xerror}\n" +) + class QueuePurge(object): """Manually initiate a purge @@ -37,23 +41,23 @@ def __init__(self, context, request): self.request = request def __call__(self): - if not isCachePurgingEnabled(): return 'Caching not enabled' registry = getUtility(IRegistry) settings = registry.forInterface(ICachePurgingSettings) - purger = getUtility(IPurger) - out = StringIO() for path in getPathsToPurge(self.context, self.request): for url in getURLsToPurge(path, settings.cachingProxies): status, xcache, xerror = purger.purgeSync(url) - out.write("Purged: " + url) - out.write(", Status: " + status) - out.write(", X-Cache: " + xcache) - out.write(", Error: " + xerror + '\n') - + out.write( + RESULT_TPL.format( + url=url, + status=status, + xcache=xcache, + xerror=xerror, + ) + ) return out.getvalue() diff --git a/plone/cachepurging/tests/test_views.py b/plone/cachepurging/tests/test_views.py index a4b5958..53baf3b 100644 --- a/plone/cachepurging/tests/test_views.py +++ b/plone/cachepurging/tests/test_views.py @@ -122,7 +122,7 @@ def test_purge(self): 'X-Cache: cached, ' 'Error: None\n' 'Purged: http://localhost:1234/bar, ' - 'Status 200 OK, ' + 'Status: 200 OK, ' 'X-Cache: cached, ' 'Error: None\n', view() diff --git a/setup.py b/setup.py index 4ca0c51..f49b2fb 100644 --- a/setup.py +++ b/setup.py @@ -10,16 +10,13 @@ open('CHANGES.rst').read()), classifiers=[ 'Framework :: Plone', - 'Framework :: Plone :: 4.0', - 'Framework :: Plone :: 4.1', - 'Framework :: Plone :: 4.2', 'Framework :: Plone :: 4.3', 'Framework :: Plone :: 5.0', 'Framework :: Plone :: 5.1', 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.6', ], keywords='plone cache purge', author='Plone Foundation',