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
f2975c02
Kaydet (Commit)
f2975c02
authored
Eyl 21, 2015
tarafından
Alasdair Nicol
Kaydeden (comit)
Tim Graham
Eyl 22, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #23813 -- Moved URLconfs into module and tidied docstrings.
üst
392f6484
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
34 deletions
+16
-34
urls.py
django/core/checks/urls.py
+5
-5
test_urls.py
tests/check_framework/test_urls.py
+7
-7
__init__.py
tests/check_framework/urls/__init__.py
+0
-0
beginning_with_slash.py
tests/check_framework/urls/beginning_with_slash.py
+1
-7
include_with_dollar.py
tests/check_framework/urls/include_with_dollar.py
+0
-0
name_with_colon.py
tests/check_framework/urls/name_with_colon.py
+1
-7
no_warnings.py
tests/check_framework/urls/no_warnings.py
+2
-8
No files found.
django/core/checks/urls.py
Dosyayı görüntüle @
f2975c02
...
...
@@ -12,7 +12,7 @@ def check_url_config(app_configs, **kwargs):
def
check_resolver
(
resolver
):
"""
Recursively check the resolver
Recursively check the resolver
.
"""
from
django.core.urlresolvers
import
RegexURLPattern
,
RegexURLResolver
warnings
=
[]
...
...
@@ -31,7 +31,7 @@ def check_resolver(resolver):
def
describe_pattern
(
pattern
):
"""
Format
s the URL pattern for display in warning messages
Format
the URL pattern for display in warning messages.
"""
description
=
"'{}'"
.
format
(
pattern
.
regex
.
pattern
)
if
getattr
(
pattern
,
'name'
,
False
):
...
...
@@ -41,7 +41,7 @@ def describe_pattern(pattern):
def
check_include_trailing_dollar
(
pattern
):
"""
Check
s
that include is not used with a regex ending with a dollar.
Check that include is not used with a regex ending with a dollar.
"""
regex_pattern
=
pattern
.
regex
.
pattern
if
regex_pattern
.
endswith
(
'$'
)
and
not
regex_pattern
.
endswith
(
'
\
$'
):
...
...
@@ -58,7 +58,7 @@ def check_include_trailing_dollar(pattern):
def
check_pattern_startswith_slash
(
pattern
):
"""
Check
s that the pattern does not begin with a forward slash
Check
that the pattern does not begin with a forward slash.
"""
regex_pattern
=
pattern
.
regex
.
pattern
if
regex_pattern
.
startswith
(
'/'
)
or
regex_pattern
.
startswith
(
'^/'
):
...
...
@@ -74,7 +74,7 @@ def check_pattern_startswith_slash(pattern):
def
check_pattern_name
(
pattern
):
"""
Check
s that the pattern name does not contain a colon
Check
that the pattern name does not contain a colon.
"""
if
pattern
.
name
is
not
None
and
":"
in
pattern
.
name
:
warning
=
Warning
(
...
...
tests/check_framework/test_urls.py
Dosyayı görüntüle @
f2975c02
...
...
@@ -4,12 +4,12 @@ from django.test.utils import override_settings
class
CheckUrlsTest
(
SimpleTestCase
):
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
_
no_warnings'
)
def
test_
include_
no_warnings
(
self
):
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
.
no_warnings'
)
def
test_no_warnings
(
self
):
result
=
check_url_config
(
None
)
self
.
assertEqual
(
result
,
[])
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
_include
'
)
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
.include_with_dollar
'
)
def
test_include_with_dollar
(
self
):
result
=
check_url_config
(
None
)
self
.
assertEqual
(
len
(
result
),
1
)
...
...
@@ -18,8 +18,8 @@ class CheckUrlsTest(SimpleTestCase):
expected_msg
=
"Your URL pattern '^include-with-dollar$' uses include with a regex ending with a '$'."
self
.
assertIn
(
expected_msg
,
warning
.
msg
)
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls_slash'
)
def
test_
url_
beginning_with_slash
(
self
):
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
.beginning_with
_slash'
)
def
test_beginning_with_slash
(
self
):
result
=
check_url_config
(
None
)
self
.
assertEqual
(
len
(
result
),
1
)
warning
=
result
[
0
]
...
...
@@ -27,8 +27,8 @@ class CheckUrlsTest(SimpleTestCase):
expected_msg
=
"Your URL pattern '/starting-with-slash/$' has a regex beginning with a '/'"
self
.
assertIn
(
expected_msg
,
warning
.
msg
)
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
_name
'
)
def
test_
url_pattern_
name_with_colon
(
self
):
@override_settings
(
ROOT_URLCONF
=
'check_framework.urls
.name_with_colon
'
)
def
test_name_with_colon
(
self
):
result
=
check_url_config
(
None
)
self
.
assertEqual
(
len
(
result
),
1
)
warning
=
result
[
0
]
...
...
tests/check_framework/urls/__init__.py
0 → 100644
Dosyayı görüntüle @
f2975c02
tests/check_framework/urls_slash.py
→
tests/check_framework/urls
/beginning_with
_slash.py
Dosyayı görüntüle @
f2975c02
from
django.conf.urls
import
include
,
url
from
django.http
import
HttpResponse
def
view
(
request
):
return
HttpResponse
(
''
)
urlpatterns
=
[
url
(
'^'
,
include
([
url
(
r'/starting-with-slash/$'
,
view
),
url
(
r'/starting-with-slash/$'
,
lambda
x
:
x
),
])),
]
tests/check_framework/urls
_include
.py
→
tests/check_framework/urls
/include_with_dollar
.py
Dosyayı görüntüle @
f2975c02
File moved
tests/check_framework/urls
_name
.py
→
tests/check_framework/urls
/name_with_colon
.py
Dosyayı görüntüle @
f2975c02
from
django.conf.urls
import
include
,
url
from
django.http
import
HttpResponse
def
view
(
request
):
return
HttpResponse
(
''
)
urlpatterns
=
[
url
(
'^'
,
include
([
url
(
r'^$'
,
view
,
name
=
'name_with:colon'
),
url
(
r'^$'
,
lambda
x
:
x
,
name
=
'name_with:colon'
),
])),
]
tests/check_framework/urls
_
no_warnings.py
→
tests/check_framework/urls
/
no_warnings.py
Dosyayı görüntüle @
f2975c02
from
django.conf.urls
import
include
,
url
from
django.http
import
HttpResponse
def
view
(
request
):
return
HttpResponse
(
''
)
urlpatterns
=
[
url
(
r'^foo/'
,
view
,
name
=
'foo'
),
url
(
r'^foo/'
,
lambda
x
:
x
,
name
=
'foo'
),
# This dollar is ok as it is escaped
url
(
r'^\$'
,
include
([
url
(
r'^bar/$'
,
view
,
name
=
'bar'
),
url
(
r'^bar/$'
,
lambda
x
:
x
,
name
=
'bar'
),
])),
]
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