Dictionary 赋值后在 MongoEngine 中变为 BaseList

Dictionary becomes BaseList in MongoEngine after assignement

我正在使用 mongoengine 0.9.0

class EntityChange(Document):
    ...
    old_data = DictField()
    new_data = DictField()

我想将 dict 个对象保存到 old_datanew_data 中。

为什么字段在分配后变为 BaseList

data = {u'int_id': 100500, u'_cls': 'BuildingKind', ...}
instance = EntityChange()
instance.new_data = data
# after that
# isinstance(instance, BaseList) is True
# isinstance(instance, BaseDict) is False
# instance.new_data == ['int_id', 'id', ...] is True. why?

Passing a dict containing _cls or _types triggered a bug in mongoengine.

A fix has been submitted 并在 0.10.1 及更高版本中合并。