Skip to content

Commit

Permalink
fix view to work on Python 2 AND 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jul 17, 2018
1 parent 5d2d9b9 commit 3795a09
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
20 changes: 12 additions & 8 deletions plone/cachepurging/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion plone/cachepurging/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3795a09

Please sign in to comment.