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
4fd264b6
Kaydet (Commit)
4fd264b6
authored
Agu 12, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24351 -- Removed support for the old allow_migrate() signature per deprecation timeline.
üst
c4e2e9de
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
61 deletions
+1
-61
utils.py
django/db/utils.py
+1
-23
multi-db.txt
docs/topics/db/multi-db.txt
+0
-6
tests.py
tests/multiple_database/tests.py
+0
-32
No files found.
django/db/utils.py
Dosyayı görüntüle @
4fd264b6
import
inspect
import
os
import
pkgutil
import
warnings
from
importlib
import
import_module
from
threading
import
local
...
...
@@ -9,7 +7,6 @@ from django.conf import settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils
import
six
from
django.utils._os
import
npath
,
upath
from
django.utils.deprecation
import
RemovedInDjango110Warning
from
django.utils.functional
import
cached_property
from
django.utils.module_loading
import
import_string
...
...
@@ -298,26 +295,7 @@ class ConnectionRouter(object):
# If the router doesn't have a method, skip to the next one.
continue
if
six
.
PY3
:
sig
=
inspect
.
signature
(
router
.
allow_migrate
)
has_deprecated_signature
=
not
any
(
p
.
kind
==
inspect
.
Parameter
.
VAR_KEYWORD
for
p
in
sig
.
parameters
.
values
()
)
else
:
argspec
=
inspect
.
getargspec
(
router
.
allow_migrate
)
has_deprecated_signature
=
len
(
argspec
.
args
)
==
3
and
not
argspec
.
keywords
if
has_deprecated_signature
:
warnings
.
warn
(
"The signature of allow_migrate has changed from "
"allow_migrate(self, db, model) to "
"allow_migrate(self, db, app_label, model_name=None, **hints). "
"Support for the old signature will be removed in Django 1.10."
,
RemovedInDjango110Warning
)
model
=
hints
.
get
(
'model'
)
allow
=
None
if
model
is
None
else
method
(
db
,
model
)
else
:
allow
=
method
(
db
,
app_label
,
**
hints
)
allow
=
method
(
db
,
app_label
,
**
hints
)
if
allow
is
not
None
:
return
allow
...
...
docs/topics/db/multi-db.txt
Dosyayı görüntüle @
4fd264b6
...
...
@@ -182,12 +182,6 @@ A database Router is a class that provides up to four methods:
keys, extra tables, or missing tables if you change it once you have
applied some migrations.
.. versionchanged:: 1.8
The signature of ``allow_migrate`` has changed significantly from previous
versions. See the :ref:`deprecation notes
<deprecated-signature-of-allow-migrate>` for more details.
A router doesn't have to provide *all* these methods -- it may omit one
or more of them. If one of the methods is omitted, Django will skip
that router when performing the relevant check.
...
...
tests/multiple_database/tests.py
Dosyayı görüntüle @
4fd264b6
...
...
@@ -2,7 +2,6 @@ from __future__ import unicode_literals
import
datetime
import
pickle
import
warnings
from
operator
import
attrgetter
from
django.contrib.auth.models
import
User
...
...
@@ -12,7 +11,6 @@ from django.db import DEFAULT_DB_ALIAS, connections, router, transaction
from
django.db.models
import
signals
from
django.db.utils
import
ConnectionRouter
from
django.test
import
SimpleTestCase
,
TestCase
,
override_settings
from
django.utils.encoding
import
force_text
from
django.utils.six
import
StringIO
from
.models
import
Book
,
Person
,
Pet
,
Review
,
UserProfile
...
...
@@ -1062,36 +1060,6 @@ class RouterTestCase(TestCase):
self
.
assertTrue
(
router
.
allow_migrate_model
(
'other'
,
User
))
self
.
assertTrue
(
router
.
allow_migrate_model
(
'other'
,
Book
))
def
test_migrate_legacy_router
(
self
):
class
LegacyRouter
(
object
):
def
allow_migrate
(
self
,
db
,
model
):
"""
Deprecated allow_migrate signature should trigger
RemovedInDjango110Warning.
"""
assert
db
==
'default'
assert
model
is
User
return
True
with
override_settings
(
DATABASE_ROUTERS
=
[
LegacyRouter
()]):
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
filterwarnings
(
'always'
)
msg
=
(
"The signature of allow_migrate has changed from "
"allow_migrate(self, db, model) to "
"allow_migrate(self, db, app_label, model_name=None, **hints). "
"Support for the old signature will be removed in Django 1.10."
)
self
.
assertTrue
(
router
.
allow_migrate_model
(
'default'
,
User
))
self
.
assertEqual
(
force_text
(
recorded
.
pop
()
.
message
),
msg
)
self
.
assertEqual
(
recorded
,
[])
self
.
assertTrue
(
router
.
allow_migrate
(
'default'
,
'app_label'
))
self
.
assertEqual
(
force_text
(
recorded
.
pop
()
.
message
),
msg
)
def
test_partial_router
(
self
):
"A router can choose to implement a subset of methods"
dive
=
Book
.
objects
.
using
(
'other'
)
.
create
(
title
=
"Dive into Python"
,
...
...
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