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
7d81ee6e
Kaydet (Commit)
7d81ee6e
authored
Eki 23, 2015
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #16734 -- Set script prefix even outside of requests
Thanks Tim Graham for the review.
üst
9dcfecb7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
5 deletions
+64
-5
__init__.py
django/__init__.py
+10
-1
wsgi.py
django/core/wsgi.py
+1
-1
applications.txt
docs/ref/applications.txt
+7
-1
settings.txt
docs/ref/settings.txt
+8
-1
1.10.txt
docs/releases/1.10.txt
+4
-1
reverse_url.py
tests/user_commands/management/commands/reverse_url.py
+10
-0
tests.py
tests/user_commands/tests.py
+19
-0
urls.py
tests/user_commands/urls.py
+5
-0
No files found.
django/__init__.py
Dosyayı görüntüle @
7d81ee6e
from
__future__
import
unicode_literals
from
django.utils.version
import
get_version
from
django.utils.version
import
get_version
VERSION
=
(
1
,
10
,
0
,
'alpha'
,
0
)
VERSION
=
(
1
,
10
,
0
,
'alpha'
,
0
)
...
@@ -5,14 +7,21 @@ VERSION = (1, 10, 0, 'alpha', 0)
...
@@ -5,14 +7,21 @@ VERSION = (1, 10, 0, 'alpha', 0)
__version__
=
get_version
(
VERSION
)
__version__
=
get_version
(
VERSION
)
def
setup
():
def
setup
(
set_prefix
=
True
):
"""
"""
Configure the settings (this happens as a side effect of accessing the
Configure the settings (this happens as a side effect of accessing the
first setting), configure logging and populate the app registry.
first setting), configure logging and populate the app registry.
Set the thread-local urlresolvers script prefix if `set_prefix` is True.
"""
"""
from
django.apps
import
apps
from
django.apps
import
apps
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
set_script_prefix
from
django.utils.encoding
import
force_text
from
django.utils.log
import
configure_logging
from
django.utils.log
import
configure_logging
configure_logging
(
settings
.
LOGGING_CONFIG
,
settings
.
LOGGING
)
configure_logging
(
settings
.
LOGGING_CONFIG
,
settings
.
LOGGING
)
if
set_prefix
:
set_script_prefix
(
'/'
if
settings
.
FORCE_SCRIPT_NAME
is
None
else
force_text
(
settings
.
FORCE_SCRIPT_NAME
)
)
apps
.
populate
(
settings
.
INSTALLED_APPS
)
apps
.
populate
(
settings
.
INSTALLED_APPS
)
django/core/wsgi.py
Dosyayı görüntüle @
7d81ee6e
...
@@ -10,5 +10,5 @@ def get_wsgi_application():
...
@@ -10,5 +10,5 @@ def get_wsgi_application():
Allows us to avoid making django.core.handlers.WSGIHandler public API, in
Allows us to avoid making django.core.handlers.WSGIHandler public API, in
case the internal WSGI implementation changes or moves in the future.
case the internal WSGI implementation changes or moves in the future.
"""
"""
django
.
setup
()
django
.
setup
(
set_prefix
=
False
)
return
WSGIHandler
()
return
WSGIHandler
()
docs/ref/applications.txt
Dosyayı görüntüle @
7d81ee6e
...
@@ -332,14 +332,20 @@ application registry.
...
@@ -332,14 +332,20 @@ application registry.
.. currentmodule:: django
.. currentmodule:: django
.. function:: setup()
.. function:: setup(
set_script=True
)
Configures Django by:
Configures Django by:
* Loading the settings.
* Loading the settings.
* Setting up logging.
* Setting up logging.
* If ``set_script`` is True, setting the URL resolver script prefix to
:setting:`FORCE_SCRIPT_NAME` if defined, or ``/`` otherwise.
* Initializing the application registry.
* Initializing the application registry.
.. versionchanged:: 1.10
The ability to set the URL resolver script prefix is new.
This function is called automatically:
This function is called automatically:
* When running an HTTP server via Django's WSGI support.
* When running an HTTP server via Django's WSGI support.
...
...
docs/ref/settings.txt
Dosyayı görüntüle @
7d81ee6e
...
@@ -1408,7 +1408,14 @@ Default: ``None``
...
@@ -1408,7 +1408,14 @@ Default: ``None``
If not ``None``, this will be used as the value of the ``SCRIPT_NAME``
If not ``None``, this will be used as the value of the ``SCRIPT_NAME``
environment variable in any HTTP request. This setting can be used to override
environment variable in any HTTP request. This setting can be used to override
the server-provided value of ``SCRIPT_NAME``, which may be a rewritten version
the server-provided value of ``SCRIPT_NAME``, which may be a rewritten version
of the preferred value or not supplied at all.
of the preferred value or not supplied at all. It is also used by
:func:`django.setup()` to set the URL resolver script prefix outside of the
request/response cycle (e.g. in management commands and standalone scripts) to
generate correct URLs when ``SCRIPT_NAME`` is not ``/``.
.. versionchanged:: 1.10
The setting's use in :func:`django.setup()` was added.
.. setting:: FORMAT_MODULE_PATH
.. setting:: FORMAT_MODULE_PATH
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
7d81ee6e
...
@@ -209,7 +209,10 @@ Tests
...
@@ -209,7 +209,10 @@ Tests
URLs
URLs
^^^^
^^^^
* ...
* An addition in :func:`django.setup()` allows URL resolving that happens
outside of the request/response cycle (e.g. in management commands and
standalone scripts) to take :setting:`FORCE_SCRIPT_NAME` into account when it
is set.
Validators
Validators
^^^^^^^^^^
^^^^^^^^^^
...
...
tests/user_commands/management/commands/reverse_url.py
0 → 100644
Dosyayı görüntüle @
7d81ee6e
from
django.core.management.base
import
BaseCommand
from
django.core.urlresolvers
import
reverse
class
Command
(
BaseCommand
):
"""
This command returns a URL from a reverse() call.
"""
def
handle
(
self
,
*
args
,
**
options
):
return
reverse
(
'some_url'
)
tests/user_commands/tests.py
Dosyayı görüntüle @
7d81ee6e
import
os
import
os
from
admin_scripts.tests
import
AdminScriptTestCase
from
django.apps
import
apps
from
django.apps
import
apps
from
django.core
import
management
from
django.core
import
management
from
django.core.management
import
BaseCommand
,
CommandError
,
find_commands
from
django.core.management
import
BaseCommand
,
CommandError
,
find_commands
...
@@ -159,6 +161,23 @@ class CommandTests(SimpleTestCase):
...
@@ -159,6 +161,23 @@ class CommandTests(SimpleTestCase):
BaseCommand
.
check
=
saved_check
BaseCommand
.
check
=
saved_check
class
CommandRunTests
(
AdminScriptTestCase
):
"""
Tests that need to run by simulating the command line, not by call_command.
"""
def
tearDown
(
self
):
self
.
remove_settings
(
'settings.py'
)
def
test_script_prefix_set_in_commands
(
self
):
self
.
write_settings
(
'settings.py'
,
apps
=
[
'user_commands'
],
sdict
=
{
'ROOT_URLCONF'
:
'"user_commands.urls"'
,
'FORCE_SCRIPT_NAME'
:
'"/PREFIX/"'
,
})
out
,
err
=
self
.
run_manage
([
'reverse_url'
])
self
.
assertNoOutput
(
err
)
self
.
assertEqual
(
out
.
strip
(),
'/PREFIX/some/url/'
)
class
UtilsTests
(
SimpleTestCase
):
class
UtilsTests
(
SimpleTestCase
):
def
test_no_existent_external_program
(
self
):
def
test_no_existent_external_program
(
self
):
...
...
tests/user_commands/urls.py
0 → 100644
Dosyayı görüntüle @
7d81ee6e
from
django.conf.urls
import
url
urlpatterns
=
[
url
(
r'^some/url/$'
,
lambda
req
:
req
,
name
=
'some_url'
),
]
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