Hi,
I am currently trying to create a document with a pretty complex nested structure (named DocC for instance):
- Some parts of the nested structure are exclusive to the document so I modelized them as SchemaDocument classes (DocB),
- other items are referenced by multiple documents, so I referenced them as separately stored documents (DocA).
The issue I have is that when I try to save the resulting structure using autorefs I get an error. The test.py illustrating example attached results in an AttributeError such as this one:
Traceback (most recent call last):
File "test.py", line 33, in <module>
dc.save()
File "/local/lib/python2.7/site-packages/mongokit/document.py", line 410, in save
self.validate(auto_migrate=False)
File "/local/lib/python2.7/site-packages/mongokit/document.py", line 228, in validate
self._make_reference(self, self.structure)
File "/local/lib/python2.7/site-packages/mongokit/document.py", line 679, in _make_reference
doc[key].save()
File "/local/lib/python2.7/site-packages/mongokit/schema_document.py", line 379, in __getattr__
return dict.__getattribute__(self, key)
AttributeError: 'DocB' object has no attribute 'save'
which leads me to think that when using autorefs mongokit also tries to save the SchemaDocument structures separately?
Commenting use_autorefs will solve the exception problem but then DocB is embedded in DocC.
Did I miss something? Is this a bug, a limitation, or a lack of understanding from me?
Regards,
Hervé