|
|
|
@ -1,3 +1,4 @@
@@ -1,3 +1,4 @@
|
|
|
|
|
from asgiref.sync import sync_to_async |
|
|
|
|
from django.http import Http404 |
|
|
|
|
from django.utils.deprecation import MiddlewareMixin |
|
|
|
|
from django_scopes import scope |
|
|
|
@ -6,11 +7,15 @@ from scopedsites.models import Domain
@@ -6,11 +7,15 @@ from scopedsites.models import Domain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DomainScopeMiddleware(MiddlewareMixin): |
|
|
|
|
async def __acall__(self, request): |
|
|
|
|
d = await sync_to_async(Domain.get_from_request)(request) |
|
|
|
|
with scope(domain=d): |
|
|
|
|
return await super().__acall__(request) |
|
|
|
|
|
|
|
|
|
def __call__(self, request): |
|
|
|
|
d = Domain.get_from_request(request) |
|
|
|
|
|
|
|
|
|
with scope(domain=d): |
|
|
|
|
return super()(request) |
|
|
|
|
return super().__call__(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DomainAutoCreateMiddleware(MiddlewareMixin): |
|
|
|
|