kopia lustrzana https://github.com/rtts/django-simplecms
Custom cache middleware that doesn't serve cached pages to logged-in users.
The hard problem of detecting whether a user is logged in is simply sidestepped by assuming that any user that sends the `sessionid` cookie is logged in. This is true as long as you don't save session variables on anonymous users (i.e. if you don't spy on them ;)main
rodzic
b3138ad1f0
commit
43c4cd281c
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from sass import compile
|
from sass import compile
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.middleware import cache
|
||||||
|
|
||||||
def locate(filename):
|
def locate(filename):
|
||||||
for path, dirs, files in os.walk(os.getcwd(), followlinks=True):
|
for path, dirs, files in os.walk(os.getcwd(), followlinks=True):
|
||||||
|
@ -8,6 +9,16 @@ def locate(filename):
|
||||||
if f == filename:
|
if f == filename:
|
||||||
yield os.path.join(path, filename)
|
yield os.path.join(path, filename)
|
||||||
|
|
||||||
|
class FetchFromCacheMiddleware(cache.FetchFromCacheMiddleware):
|
||||||
|
'''Minor change to the original middleware that prevents caching of
|
||||||
|
requests that have a `sessionid` cookie. This should be the
|
||||||
|
Django default, IMHO.
|
||||||
|
|
||||||
|
'''
|
||||||
|
def process_request(self, request):
|
||||||
|
if 'sessionid' not in request.COOKIES:
|
||||||
|
return super().process_request(request)
|
||||||
|
|
||||||
class SassMiddleware:
|
class SassMiddleware:
|
||||||
'''Simple SASS middleware that intercepts requests for .css files and
|
'''Simple SASS middleware that intercepts requests for .css files and
|
||||||
tries to compile the corresponding SCSS file.
|
tries to compile the corresponding SCSS file.
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'django-simplecms',
|
name = 'django-simplecms',
|
||||||
version = '1.0.1',
|
version = '1.0.2',
|
||||||
url = 'https://github.com/rtts/django-simplecms',
|
url = 'https://github.com/rtts/django-simplecms',
|
||||||
author = 'Jaap Joris Vens',
|
author = 'Jaap Joris Vens',
|
||||||
author_email = 'jj@rtts.eu',
|
author_email = 'jj@rtts.eu',
|
||||||
|
|
Ładowanie…
Reference in New Issue