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
64e11a68
Kaydet (Commit)
64e11a68
authored
May 18, 2013
tarafından
Łukasz Langa
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #13285: populate_xheaders breaks caching
üst
63a9555d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
5 additions
and
148 deletions
+5
-148
views.py
django/contrib/flatpages/views.py
+0
-2
xheaders.py
django/core/xheaders.py
+0
-24
1.6.txt
docs/releases/1.6.txt
+5
-0
__init__.py
tests/special_headers/__init__.py
+0
-0
data.xml
tests/special_headers/fixtures/data.xml
+0
-20
models.py
tests/special_headers/models.py
+0
-5
article_detail.html
...ial_headers/templates/special_headers/article_detail.html
+0
-1
tests.py
tests/special_headers/tests.py
+0
-62
urls.py
tests/special_headers/urls.py
+0
-13
views.py
tests/special_headers/views.py
+0
-21
No files found.
django/contrib/flatpages/views.py
Dosyayı görüntüle @
64e11a68
from
django.conf
import
settings
from
django.contrib.flatpages.models
import
FlatPage
from
django.contrib.sites.models
import
get_current_site
from
django.core.xheaders
import
populate_xheaders
from
django.http
import
Http404
,
HttpResponse
,
HttpResponsePermanentRedirect
from
django.shortcuts
import
get_object_or_404
from
django.template
import
loader
,
RequestContext
...
...
@@ -70,5 +69,4 @@ def render_flatpage(request, f):
'flatpage'
:
f
,
})
response
=
HttpResponse
(
t
.
render
(
c
))
populate_xheaders
(
request
,
response
,
FlatPage
,
f
.
id
)
return
response
django/core/xheaders.py
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
"""
Pages in Django can are served up with custom HTTP headers containing useful
information about those pages -- namely, the content type and object ID.
This module contains utility functions for retrieving and doing interesting
things with these special "X-Headers" (so called because the HTTP spec demands
that custom headers are prefixed with "X-").
Next time you're at slashdot.org, watch out for X-Fry and X-Bender. :)
"""
def
populate_xheaders
(
request
,
response
,
model
,
object_id
):
"""
Adds the "X-Object-Type" and "X-Object-Id" headers to the given
HttpResponse according to the given model and object_id -- but only if the
given HttpRequest object has an IP address within the INTERNAL_IPS setting
or if the request is from a logged in staff member.
"""
from
django.conf
import
settings
if
(
request
.
META
.
get
(
'REMOTE_ADDR'
)
in
settings
.
INTERNAL_IPS
or
(
hasattr
(
request
,
'user'
)
and
request
.
user
.
is_active
and
request
.
user
.
is_staff
)):
response
[
'X-Object-Type'
]
=
"
%
s.
%
s"
%
(
model
.
_meta
.
app_label
,
model
.
_meta
.
model_name
)
response
[
'X-Object-Id'
]
=
str
(
object_id
)
docs/releases/1.6.txt
Dosyayı görüntüle @
64e11a68
...
...
@@ -491,6 +491,11 @@ Miscellaneous
memcache backend no longer uses the default timeout, and now will
set-and-expire-immediately the value.
* The ``django.contrib.flatpages`` app used to set custom HTTP headers for
debugging purposes. This functionality was not documented and made caching
ineffective so it has been removed, along with its generic implementation,
previously available in ``django.core.xheaders``.
Features deprecated in 1.6
==========================
...
...
tests/special_headers/__init__.py
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
tests/special_headers/fixtures/data.xml
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
<?xml version="1.0" encoding="utf-8"?>
<django-objects
version=
"1.0"
>
<object
pk=
"100"
model=
"auth.user"
>
<field
type=
"CharField"
name=
"username"
>
super
</field>
<field
type=
"CharField"
name=
"first_name"
>
Super
</field>
<field
type=
"CharField"
name=
"last_name"
>
User
</field>
<field
type=
"CharField"
name=
"email"
>
super@example.com
</field>
<field
type=
"CharField"
name=
"password"
>
sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158
</field>
<field
type=
"BooleanField"
name=
"is_staff"
>
True
</field>
<field
type=
"BooleanField"
name=
"is_active"
>
True
</field>
<field
type=
"BooleanField"
name=
"is_superuser"
>
True
</field>
<field
type=
"DateTimeField"
name=
"last_login"
>
2007-05-30 13:20:10
</field>
<field
type=
"DateTimeField"
name=
"date_joined"
>
2007-05-30 13:20:10
</field>
<field
to=
"auth.group"
name=
"groups"
rel=
"ManyToManyRel"
></field>
<field
to=
"auth.permission"
name=
"user_permissions"
rel=
"ManyToManyRel"
></field>
</object>
<object
pk=
"1"
model=
"special_headers.article"
>
<field
type=
"TextField"
name=
"text"
>
text
</field>
</object>
</django-objects>
tests/special_headers/models.py
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
from
django.db
import
models
class
Article
(
models
.
Model
):
text
=
models
.
TextField
()
tests/special_headers/templates/special_headers/article_detail.html
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
{{ object }}
tests/special_headers/tests.py
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,))
class
SpecialHeadersTest
(
TestCase
):
fixtures
=
[
'data.xml'
]
urls
=
'special_headers.urls'
def
test_xheaders
(
self
):
user
=
User
.
objects
.
get
(
username
=
'super'
)
response
=
self
.
client
.
get
(
'/special_headers/article/1/'
)
self
.
assertFalse
(
'X-Object-Type'
in
response
)
self
.
client
.
login
(
username
=
'super'
,
password
=
'secret'
)
response
=
self
.
client
.
get
(
'/special_headers/article/1/'
)
self
.
assertTrue
(
'X-Object-Type'
in
response
)
user
.
is_staff
=
False
user
.
save
()
response
=
self
.
client
.
get
(
'/special_headers/article/1/'
)
self
.
assertFalse
(
'X-Object-Type'
in
response
)
user
.
is_staff
=
True
user
.
is_active
=
False
user
.
save
()
response
=
self
.
client
.
get
(
'/special_headers/article/1/'
)
self
.
assertFalse
(
'X-Object-Type'
in
response
)
def
test_xview_func
(
self
):
user
=
User
.
objects
.
get
(
username
=
'super'
)
response
=
self
.
client
.
head
(
'/special_headers/xview/func/'
)
self
.
assertFalse
(
'X-View'
in
response
)
self
.
client
.
login
(
username
=
'super'
,
password
=
'secret'
)
response
=
self
.
client
.
head
(
'/special_headers/xview/func/'
)
self
.
assertTrue
(
'X-View'
in
response
)
self
.
assertEqual
(
response
[
'X-View'
],
'special_headers.views.xview'
)
user
.
is_staff
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/special_headers/xview/func/'
)
self
.
assertFalse
(
'X-View'
in
response
)
user
.
is_staff
=
True
user
.
is_active
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/special_headers/xview/func/'
)
self
.
assertFalse
(
'X-View'
in
response
)
def
test_xview_class
(
self
):
user
=
User
.
objects
.
get
(
username
=
'super'
)
response
=
self
.
client
.
head
(
'/special_headers/xview/class/'
)
self
.
assertFalse
(
'X-View'
in
response
)
self
.
client
.
login
(
username
=
'super'
,
password
=
'secret'
)
response
=
self
.
client
.
head
(
'/special_headers/xview/class/'
)
self
.
assertTrue
(
'X-View'
in
response
)
self
.
assertEqual
(
response
[
'X-View'
],
'special_headers.views.XViewClass'
)
user
.
is_staff
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/special_headers/xview/class/'
)
self
.
assertFalse
(
'X-View'
in
response
)
user
.
is_staff
=
True
user
.
is_active
=
False
user
.
save
()
response
=
self
.
client
.
head
(
'/special_headers/xview/class/'
)
self
.
assertFalse
(
'X-View'
in
response
)
tests/special_headers/urls.py
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
# coding: utf-8
from
__future__
import
absolute_import
from
django.conf.urls
import
patterns
from
.
import
views
from
.models
import
Article
urlpatterns
=
patterns
(
''
,
(
r'^special_headers/article/(?P<object_id>\d+)/$'
,
views
.
xview_xheaders
),
(
r'^special_headers/xview/func/$'
,
views
.
xview_dec
(
views
.
xview
)),
(
r'^special_headers/xview/class/$'
,
views
.
xview_dec
(
views
.
XViewClass
.
as_view
())),
)
tests/special_headers/views.py
deleted
100644 → 0
Dosyayı görüntüle @
63a9555d
from
django.core.xheaders
import
populate_xheaders
from
django.http
import
HttpResponse
from
django.utils.decorators
import
decorator_from_middleware
from
django.views.generic
import
View
from
django.middleware.doc
import
XViewMiddleware
from
.models
import
Article
xview_dec
=
decorator_from_middleware
(
XViewMiddleware
)
def
xview
(
request
):
return
HttpResponse
()
def
xview_xheaders
(
request
,
object_id
):
response
=
HttpResponse
()
populate_xheaders
(
request
,
response
,
Article
,
1
)
return
response
class
XViewClass
(
View
):
def
get
(
self
,
request
):
return
HttpResponse
()
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