-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
I am trying to set an EmbeddedDocument as a value in a DictField, which according to #99 should work. However, when I do so, I receive the following error:
bson.errors.InvalidDocument: cannot encode object: <object EmbeddedDocument objects.items.MockItem({'uuid': UUID('cee1f505-1014-4bc8-9095-7047c869587c'), '_token_id': '1583', 'durability': 100})>, of type: <Implementation class 'objects.items.MockItem'>
The DictField's definition:
_slots = fields.DictField(attribute="slots")The MockItem EmbeddedDocument:
instance.register
class MockItem(EmbeddedDocument):
"""An item with associated durability."""
uuid = fields.UUIDField(default=uuid.uuid4)
_token_id = fields.StrField(required=True, attribute="tokenId")
durability = fields.IntField(default=100)
_item = None
# Custom __getattr__ and __hash__ omittedStepping through the debugger, prior to attempting to commit(), the _slots dict has the following value:
<object umongo.data_objects.Dict({'base': None, 'pet': None, 'cloak': None, 'oh': None, 'body': None, 'hair': None, 'ears': None, 'face': None, 'legs': None, 'feet': None, 'chest': None, 'hands': None, 'waist': None, 'head': None, 'mh': <object EmbeddedDocument objects.items.MockItem({'uuid': UUID('d28a07c1-49b3-4099-be44-4733d04420cd'), '_token_id': '-104', 'durability': 100})>})>In my AsyncioMotorClient, I am setting uuidRepresentation="standard", but I get the error with or without the UUID field present. What am I doing wrong?
pyfection
Metadata
Metadata
Assignees
Labels
No labels