Browse Source

might work now lol

main
Julia Luna 2 years ago
parent
commit
0d9c028ddb
Signed by: xenua
GPG Key ID: 6A0C04FA9A7D7582
  1. 9
      scopedsites/middleware.py
  2. 2
      setup.py

9
scopedsites/middleware.py

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

2
setup.py

@ -3,7 +3,7 @@ from setuptools import setup
setup( setup(
name="django_scopedsites", name="django_scopedsites",
packages=["scopedsites", "scopedsites.migrations"], packages=["scopedsites", "scopedsites.migrations"],
version="0.1.7", version="0.1.8",
description="django_scopes x django.contrib.sites", description="django_scopes x django.contrib.sites",
python_requires=">=3.6", python_requires=">=3.6",
install_requires=[ install_requires=[

Loading…
Cancel
Save