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
fff86cfa
Kaydet (Commit)
fff86cfa
authored
Ara 08, 2017
tarafından
Jozef
Kaydeden (comit)
Tim Graham
Ara 08, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Made session loading in cached_db engine more DRY.
üst
c5a2f48b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
20 deletions
+9
-20
cached_db.py
django/contrib/sessions/backends/cached_db.py
+3
-16
db.py
django/contrib/sessions/backends/db.py
+6
-4
No files found.
django/contrib/sessions/backends/cached_db.py
Dosyayı görüntüle @
fff86cfa
...
...
@@ -2,13 +2,9 @@
Cached, database-backed sessions.
"""
import
logging
from
django.conf
import
settings
from
django.contrib.sessions.backends.db
import
SessionStore
as
DBStore
from
django.core.cache
import
caches
from
django.core.exceptions
import
SuspiciousOperation
from
django.utils
import
timezone
KEY_PREFIX
=
"django.contrib.sessions.cached_db"
...
...
@@ -36,20 +32,11 @@ class SessionStore(DBStore):
data
=
None
if
data
is
None
:
# Duplicate DBStore.load, because we need to keep track
# of the expiry date to set it properly in the cache.
try
:
s
=
self
.
model
.
objects
.
get
(
session_key
=
self
.
session_key
,
expire_date__gt
=
timezone
.
now
()
)
s
=
self
.
_get_session_from_db
()
if
s
:
data
=
self
.
decode
(
s
.
session_data
)
self
.
_cache
.
set
(
self
.
cache_key
,
data
,
self
.
get_expiry_age
(
expiry
=
s
.
expire_date
))
except
(
self
.
model
.
DoesNotExist
,
SuspiciousOperation
)
as
e
:
if
isinstance
(
e
,
SuspiciousOperation
):
logger
=
logging
.
getLogger
(
'django.security.
%
s'
%
e
.
__class__
.
__name__
)
logger
.
warning
(
str
(
e
))
self
.
_session_key
=
None
else
:
data
=
{}
return
data
...
...
django/contrib/sessions/backends/db.py
Dosyayı görüntüle @
fff86cfa
...
...
@@ -27,19 +27,21 @@ class SessionStore(SessionBase):
def
model
(
self
):
return
self
.
get_model_class
()
def
load
(
self
):
def
_get_session_from_db
(
self
):
try
:
s
=
self
.
model
.
objects
.
get
(
return
self
.
model
.
objects
.
get
(
session_key
=
self
.
session_key
,
expire_date__gt
=
timezone
.
now
()
)
return
self
.
decode
(
s
.
session_data
)
except
(
self
.
model
.
DoesNotExist
,
SuspiciousOperation
)
as
e
:
if
isinstance
(
e
,
SuspiciousOperation
):
logger
=
logging
.
getLogger
(
'django.security.
%
s'
%
e
.
__class__
.
__name__
)
logger
.
warning
(
str
(
e
))
self
.
_session_key
=
None
return
{}
def
load
(
self
):
s
=
self
.
_get_session_from_db
()
return
self
.
decode
(
s
.
session_data
)
if
s
else
{}
def
exists
(
self
,
session_key
):
return
self
.
model
.
objects
.
filter
(
session_key
=
session_key
)
.
exists
()
...
...
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