Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update docstrings
=e6af92f19a9b
diff --git a/saleor/core/middleware.py b/saleor/core/middleware.pyindex 992c4c8a75..dd74e54355 100644--- a/saleor/core/middleware.py+++ b/saleor/core/middleware.py@@ -53,6 +53,16 @@ class CurrencyMiddleware(object):class ClearSiteCacheMiddleware(object):+ """+ This middleware clears the Sites cache, refetches the current Site+ and sets it as attribute in request object for future uses in this+ request cycle.+ By default django.contrib.sites caches Site instances at the module+ level, which leads to problems when updating Site instances, such+ as necessity to restart the application server in order to invalidate+ the cache. Using this middleware solves this problem.+ """+def process_request(self, request):Site.objects.clear_cache()request.site = Site.objects.get_current()diff --git a/saleor/site/patch_sites.py b/saleor/site/patch_sites.pyindex 96476bb0a3..6ca74c1d46 100644--- a/saleor/site/patch_sites.py+++ b/saleor/site/patch_sites.py@@ -1,3 +1,9 @@+'''+Since django.contrib.sites may not be thread-safe when there are+multiple instances of the application server, we're patching it with+a thread-safe structure and methods that use it underneath.+'''+import threadingfrom django.contrib.sites.models import SiteManager@@ -5,17 +11,6 @@ from django.core.exceptions import ImproperlyConfiguredfrom django.http.request import split_domain_port-'''-We are patching django.contrib.sites because it is cached on module level and-can be in some cases thread unsafe. Also django.contrib.sites can be used by-other modules and we don't want to lose its functionality. Saleor has its own-SiteSetting, but having those settings in two places is not what we wanted.-Instead we link django.contrib.sites and saleor Site.Settings with One To One-relationship.-In this patch we are also prefetching our settings for better performance.-'''--lock = threading.Lock()with lock:THREADED_SITE_CACHE = {}