Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
5e3f4c2e
Kaydet (Commit)
5e3f4c2e
authored
Haz 07, 2016
tarafından
Brett Haydon
Kaydeden (comit)
Tim Graham
Haz 07, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26716 -- Made CurrentSiteMiddleware compatible with new-style middleware.
üst
908c26b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
middleware.py
django/contrib/sites/middleware.py
+3
-1
tests.py
tests/sites_tests/tests.py
+8
-2
No files found.
django/contrib/sites/middleware.py
Dosyayı görüntüle @
5e3f4c2e
from
django.utils.deprecation
import
MiddlewareMixin
from
.shortcuts
import
get_current_site
class
CurrentSiteMiddleware
(
object
):
class
CurrentSiteMiddleware
(
MiddlewareMixin
):
"""
Middleware that sets `site` attribute to request object.
"""
...
...
tests/sites_tests/tests.py
Dosyayı görüntüle @
5e3f4c2e
...
...
@@ -11,7 +11,7 @@ from django.contrib.sites.requests import RequestSite
from
django.contrib.sites.shortcuts
import
get_current_site
from
django.core.exceptions
import
ObjectDoesNotExist
,
ValidationError
from
django.db.models.signals
import
post_migrate
from
django.http
import
HttpRequest
from
django.http
import
HttpRequest
,
HttpResponse
from
django.test
import
TestCase
,
modify_settings
,
override_settings
from
django.test.utils
import
captured_stdout
...
...
@@ -305,9 +305,15 @@ class CreateDefaultSiteTests(TestCase):
class
MiddlewareTest
(
TestCase
):
def
test_request
(
self
):
def
test_
old_style_
request
(
self
):
""" Makes sure that the request has correct `site` attribute. """
middleware
=
CurrentSiteMiddleware
()
request
=
HttpRequest
()
middleware
.
process_request
(
request
)
self
.
assertEqual
(
request
.
site
.
id
,
settings
.
SITE_ID
)
def
test_request
(
self
):
def
get_response
(
request
):
return
HttpResponse
(
str
(
request
.
site
.
id
))
response
=
CurrentSiteMiddleware
(
get_response
)(
HttpRequest
())
self
.
assertContains
(
response
,
settings
.
SITE_ID
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment