Merge pull request #1925 from mixxorz/frontendcache-invalidator-python2

Add Python < 3.3 support for frontendcache invalidator
pull/468/merge
Karl Hobley 2015-11-17 11:01:49 +00:00
commit 64db11b35e
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -11,6 +11,11 @@ from wagtail.wagtailcore import __version__
logger = logging.getLogger('wagtail.frontendcache')
class PurgeRequest(Request):
def get_method(self):
return 'PURGE'
class BaseBackend(object):
def purge(self, url):
raise NotImplementedError
@ -30,7 +35,7 @@ class HTTPBackend(BaseBackend):
if url_parsed.port:
host += (':' + str(url_parsed.port))
request = Request(
request = PurgeRequest(
url=urlunparse([
self.cache_scheme,
self.cache_netloc,
@ -42,8 +47,7 @@ class HTTPBackend(BaseBackend):
headers={
'Host': host,
'User-Agent': 'Wagtail-frontendcache/' + __version__
},
method='PURGE'
}
)
try: