Commit a9b8b0ef by Matt Drayer

Merge pull request #20 from edx/saleem-latif/WL-322-test-failure

WL-322: Set WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS to None if settings is not configured
parents 614c5686 77caec3d
...@@ -3,9 +3,16 @@ import importlib ...@@ -3,9 +3,16 @@ import importlib
from django.conf import settings from django.conf import settings
if getattr(settings, "WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS", None): # Take WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS from django settings, if settings is not configured or of
class_name = settings.WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS.split(".")[-1] # WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS setting is not defined then use custom middleware from django-wiki
module = ".".join(settings.WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS.split('.')[:-1]) if hasattr(settings, "WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS"):
WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS = settings.WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS
else:
WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS = None
if WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS:
class_name = WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS.split(".")[-1]
module = ".".join(WIKI_REQUEST_CACHE_MIDDLEWARE_CLASS.split('.')[:-1])
RequestCache = getattr(importlib.import_module(module), class_name) RequestCache = getattr(importlib.import_module(module), class_name)
else: else:
class _RequestCache(threading.local): class _RequestCache(threading.local):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment