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
183fb7b2
Kaydet (Commit)
183fb7b2
authored
Ara 01, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Ara 06, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28870 -- Added support for functools.partialmethod serialization in migrations.
üst
b728ab22
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
6 deletions
+21
-6
serializer.py
django/db/migrations/serializer.py
+6
-3
2.1.txt
docs/releases/2.1.txt
+1
-1
migrations.txt
docs/topics/migrations.txt
+6
-2
test_writer.py
tests/migrations/test_writer.py
+8
-0
No files found.
django/db/migrations/serializer.py
Dosyayı görüntüle @
183fb7b2
...
...
@@ -171,8 +171,11 @@ class FunctoolsPartialSerializer(BaseSerializer):
imports
.
update
(
args_imports
)
imports
.
update
(
keywords_imports
)
return
(
"functools.partial(
%
s, *
%
s, **
%
s)"
%
(
func_string
,
args_string
,
keywords_string
,
'functools.
%
s(
%
s, *
%
s, **
%
s)'
%
(
self
.
value
.
__class__
.
__name__
,
func_string
,
args_string
,
keywords_string
,
),
imports
,
)
...
...
@@ -340,7 +343,7 @@ def serializer_factory(value):
return
BaseSimpleSerializer
(
value
)
if
isinstance
(
value
,
decimal
.
Decimal
):
return
DecimalSerializer
(
value
)
if
isinstance
(
value
,
functools
.
partial
):
if
isinstance
(
value
,
(
functools
.
partial
,
functools
.
partialmethod
)
):
return
FunctoolsPartialSerializer
(
value
)
if
isinstance
(
value
,
(
types
.
FunctionType
,
types
.
BuiltinFunctionType
,
types
.
MethodType
)):
return
FunctionTypeSerializer
(
value
)
...
...
docs/releases/2.1.txt
Dosyayı görüntüle @
183fb7b2
...
...
@@ -150,7 +150,7 @@ Management Commands
Migrations
~~~~~~~~~~
*
..
.
*
Added support for serialization of ``functools.partialmethod`` objects
.
Models
~~~~~~
...
...
docs/topics/migrations.txt
Dosyayı görüntüle @
183fb7b2
...
...
@@ -661,8 +661,8 @@ Django can serialize the following:
- ``decimal.Decimal`` instances
- ``enum.Enum`` instances
- ``uuid.UUID`` instances
-
``functools.partial`` instances which have serializable ``func``, ``args``,
and ``keywords`` values.
-
:func:`functools.partial` and :class:`functools.partialmethod` instances
which have serializable ``func``, ``args``,
and ``keywords`` values.
- ``LazyObject`` instances which wrap a serializable value.
- Any Django field
- Any function or method reference (e.g. ``datetime.datetime.today``) (must be in module's top-level scope)
...
...
@@ -670,6 +670,10 @@ Django can serialize the following:
- Any class reference (must be in module's top-level scope)
- Anything with a custom ``deconstruct()`` method (:ref:`see below <custom-deconstruct-method>`)
.. versionchanged:: 2.1
Serialization support for :class:`functools.partialmethod` was added.
Django cannot serialize:
- Nested classes
...
...
tests/migrations/test_writer.py
Dosyayı görüntüle @
183fb7b2
...
...
@@ -520,6 +520,14 @@ class WriterTests(SimpleTestCase):
self
.
assertEqual
(
result
.
args
,
value
.
args
)
self
.
assertEqual
(
result
.
keywords
,
value
.
keywords
)
def
test_serialize_functools_partialmethod
(
self
):
value
=
functools
.
partialmethod
(
datetime
.
timedelta
,
1
,
seconds
=
2
)
result
=
self
.
serialize_round_trip
(
value
)
self
.
assertIsInstance
(
result
,
functools
.
partialmethod
)
self
.
assertEqual
(
result
.
func
,
value
.
func
)
self
.
assertEqual
(
result
.
args
,
value
.
args
)
self
.
assertEqual
(
result
.
keywords
,
value
.
keywords
)
def
test_simple_migration
(
self
):
"""
Tests serializing a simple migration.
...
...
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