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
efddae25
Kaydet (Commit)
efddae25
authored
Ara 27, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactored dumpdata with app configs instead of models modules.
üst
40b87676
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
dumpdata.py
django/core/management/commands/dumpdata.py
+19
-24
No files found.
django/core/management/commands/dumpdata.py
Dosyayı görüntüle @
efddae25
...
...
@@ -3,6 +3,7 @@ import warnings
from
collections
import
OrderedDict
from
optparse
import
make_option
from
django.apps
import
apps
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core
import
serializers
from
django.db
import
router
,
DEFAULT_DB_ALIAS
...
...
@@ -37,8 +38,6 @@ class Command(BaseCommand):
args
=
'[appname appname.ModelName ...]'
def
handle
(
self
,
*
app_labels
,
**
options
):
from
django.apps
import
apps
format
=
options
.
get
(
'format'
)
indent
=
options
.
get
(
'indent'
)
using
=
options
.
get
(
'database'
)
...
...
@@ -63,24 +62,23 @@ class Command(BaseCommand):
for
exclude
in
excludes
:
if
'.'
in
exclude
:
app_label
,
model_name
=
exclude
.
split
(
'.'
,
1
)
model
_obj
=
apps
.
get_model
(
app_label
,
model_name
)
if
not
model
_obj
:
model
=
apps
.
get_model
(
app_label
,
model_name
)
if
not
model
:
raise
CommandError
(
'Unknown model in excludes:
%
s'
%
exclude
)
excluded_models
.
add
(
model
_obj
)
excluded_models
.
add
(
model
)
else
:
try
:
app_obj
=
apps
.
get_app_config
(
exclude
)
.
models_module
if
app_obj
is
not
None
:
excluded_apps
.
add
(
app_obj
)
app_config
=
apps
.
get_app_config
(
exclude
)
except
LookupError
:
raise
CommandError
(
'Unknown app in excludes:
%
s'
%
exclude
)
excluded_apps
.
add
(
app_config
)
if
len
(
app_labels
)
==
0
:
if
primary_keys
:
raise
CommandError
(
"You can only use --pks option with one model"
)
app_list
=
OrderedDict
((
app_config
.
models_module
,
None
)
app_list
=
OrderedDict
((
app_config
,
None
)
for
app_config
in
apps
.
get_app_configs
(
only_with_models_module
=
True
)
if
app_config
.
models_module
not
in
excluded_apps
)
if
app_config
not
in
excluded_apps
)
else
:
if
len
(
app_labels
)
>
1
and
primary_keys
:
raise
CommandError
(
"You can only use --pks option with one model"
)
...
...
@@ -89,32 +87,30 @@ class Command(BaseCommand):
try
:
app_label
,
model_label
=
label
.
split
(
'.'
)
try
:
app
=
apps
.
get_app_config
(
app_label
)
.
models_module
app
_config
=
apps
.
get_app_config
(
app_label
)
except
LookupError
:
raise
CommandError
(
"Unknown application:
%
s"
%
app_label
)
if
app
is
None
or
app
in
excluded_apps
:
if
app
_config
.
models_module
is
None
or
app_config
in
excluded_apps
:
continue
model
=
apps
.
get_model
(
app_label
,
model_label
)
if
model
is
None
:
raise
CommandError
(
"Unknown model:
%
s.
%
s"
%
(
app_label
,
model_label
))
if
app
in
app_list
.
keys
():
if
app_list
[
app
]
and
model
not
in
app_list
[
app
]:
app_list
[
app
]
.
append
(
model
)
else
:
app_list
[
app
]
=
[
model
]
app_list_value
=
app_list
.
setdefault
(
app_config
,
[])
if
model
not
in
app_list_value
:
app_list_value
.
append
(
model
)
except
ValueError
:
if
primary_keys
:
raise
CommandError
(
"You can only use --pks option with one model"
)
# This is just an app - no model qualifier
app_label
=
label
try
:
app
=
apps
.
get_app_config
(
app_label
)
.
models_module
app
_config
=
apps
.
get_app_config
(
app_label
)
except
LookupError
:
raise
CommandError
(
"Unknown application:
%
s"
%
app_label
)
if
app
is
None
or
app
in
excluded_apps
:
if
app
_config
.
models_module
is
None
or
app_config
in
excluded_apps
:
continue
app_list
[
app
]
=
None
app_list
[
app
_config
]
=
None
# Check that the serialization format exists; this is a shortcut to
# avoid collating all the objects and _then_ failing.
...
...
@@ -156,19 +152,18 @@ class Command(BaseCommand):
def
sort_dependencies
(
app_list
):
"""Sort a list of
app,modellist
pairs into a single list of models.
"""Sort a list of
(app_config, models)
pairs into a single list of models.
The single list of models is sorted so that any model with a natural key
is serialized before a normal model, and any model with a natural key
dependency has it's dependencies serialized first.
"""
from
django.apps
import
apps
# Process the list of models, and get the list of dependencies
model_dependencies
=
[]
models
=
set
()
for
app
,
model_list
in
app_list
:
for
app
_config
,
model_list
in
app_list
:
if
model_list
is
None
:
model_list
=
apps
.
get_models
(
app
)
model_list
=
apps
.
get_models
(
app
_config
.
models_module
)
for
model
in
model_list
:
models
.
add
(
model
)
...
...
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