I have some troubles with the _data
attribute of a mongoengine Document
instance after upgrading from version 0.10.0 to 0.10.6
I define a class inheriting from Document
from mongoengine import *
__all__ = ('User',)
connect('mydb')
class User(Document):
user_id = IntField(unique=True)
username = StringField()
meta = {'indexes': ['user_id','username'],
'index_background' : True}
Until now, I used mongoengine
version 0.10.0
To access the dict of data a User
instance, I used to deal with the _data
attribute.
In [1]: User.objects.first()._data
Out[1]:
{'id':ObjectId('55b6290a10976a2a0908f8a3'),
'user_id': 1,
'username': "fake_user"}
In [15]: type(User.objects.first()._data)
Out[15]: dict
Now, I upgraded the version of mongoengine
to version 0.10.6
In [2]: User.objects.first()._data
Out[2]:
{"id": 'id',
"user_id": 'user_id',
"username": 'username'}
In [2]: type(User.objects.first()._data)
Out[2]: mongoengine.base.datastructures.SpecificStrictDict
So _data
attribute is no longer of type dict
and my code breaks when I try to store a list of users in a pandas.DataFrame
doing :
df = pandas.DataFrame([u._data for u in User.objects])
I can't find any explanation in mongoengine changelog doc here
Can somebody explain me what is this mongoengine.base.datastructures.SpecificStrictDict
? and how it works ?