Skip to content

Commit

Permalink
Merge pull request #26 from plone/overhaul
Browse files Browse the repository at this point in the history
Overhaul: py3/black/...
  • Loading branch information
jensens authored May 5, 2022
2 parents 3e27e92 + 4a5e656 commit 7ec00fb
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 509 deletions.
217 changes: 0 additions & 217 deletions bootstrap.py

This file was deleted.

7 changes: 0 additions & 7 deletions bootstrap.sh

This file was deleted.

18 changes: 0 additions & 18 deletions buildout.cfg

This file was deleted.

2 changes: 2 additions & 0 deletions news/26.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Drop Python 2 support. Code style.
[jensens]
1 change: 0 additions & 1 deletion plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
__import__("pkg_resources").declare_namespace(__name__)
30 changes: 14 additions & 16 deletions plone/cachepurging/browser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.cachepurging.interfaces import ICachePurgingSettings
from plone.cachepurging.interfaces import IPurger
from plone.cachepurging.utils import getPathsToPurge
Expand All @@ -10,28 +9,26 @@
from zope.event import notify


class QueuePurge(object):
"""Manually initiate a purge
"""
class QueuePurge:
"""Manually initiate a purge"""

def __init__(self, context, request):
self.context = context
self.request = request

def __call__(self):
self.request.response.setHeader('Content-type', 'text/plain')
self.request.response.setHeader("Content-type", "text/plain")
if not isCachePurgingEnabled():
return "Cache purging not enabled"

paths = getPathsToPurge(self.context, self.request)

notify(Purge(self.context))
return "Queued:\n\n{0}".format("\n".join(paths))
return "Queued:\n\n{}".format("\n".join(paths))


class PurgeImmediately(object):
"""Purge immediately
"""
class PurgeImmediately:
"""Purge immediately"""

def __init__(self, context, request):
self.context = context
Expand All @@ -43,7 +40,7 @@ def write(self, msg):
self.request.response.write(msg)

def __call__(self):
self.request.response.setHeader('Content-type', 'text/plain')
self.request.response.setHeader("Content-type", "text/plain")
if not isCachePurgingEnabled():
return "Cache purging not enabled"

Expand All @@ -54,17 +51,18 @@ def __call__(self):
caching_proxies = settings.cachingProxies
traceback = self.request.form.get("traceback")
if not traceback:
self.write("(hint: add '?traceback' to url to show full traceback in case of errors)\n\n")
self.write("Proxies to purge: {0}\n".format(', '.join(caching_proxies)))
self.write(
"(hint: add '?traceback' to url to show full traceback in case of errors)\n\n"
)
self.write("Proxies to purge: {}\n".format(", ".join(caching_proxies)))
for path in getPathsToPurge(self.context, self.request):
self.write("- process path: {0}\n".format(path))
self.write(f"- process path: {path}\n")
for url in getURLsToPurge(path, caching_proxies):
self.write(" - send to purge {0}\n".format(url).encode("utf-8"))
self.write(f" - send to purge {url}\n".encode("utf-8"))
status, xcache, xerror = purger.purgeSync(url)
self.write(
" response with status: {status}, X-Cache: {xcache}\n".format(
status=status,
xcache=xcache
status=status, xcache=xcache
)
)
if traceback and xerror:
Expand Down
7 changes: 2 additions & 5 deletions plone/cachepurging/hooks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from plone.cachepurging.interfaces import ICachePurgingSettings
from plone.cachepurging.interfaces import IPurger
from plone.cachepurging.utils import getPathsToPurge
Expand All @@ -18,8 +17,7 @@

@adapter(IPurgeEvent)
def queuePurge(event):
"""Find URLs to purge and queue them for later
"""
"""Find URLs to purge and queue them for later"""

request = getRequest()
if request is None:
Expand All @@ -38,8 +36,7 @@ def queuePurge(event):

@adapter(IPubSuccess)
def purge(event):
"""Asynchronously send PURGE requests
"""
"""Asynchronously send PURGE requests"""

request = event.request

Expand Down
Loading

0 comments on commit 7ec00fb

Please sign in to comment.