I expected that the following code will print all key/value pairs from the document with key existing_document_key:
doc = connection['your_database']['your_collection']['existing_document_key']
for key, value in dict(doc).items():
print(f'{key}: {value}')
But it causes a TypeError: 'NoneType' object is not callable exception in the for key, value in dict(doc).items(): line. After some digging, it looks as if the __dict__ implementation of the pyArango.document.Document class is not correct:
def __dict__(self):
if not self._store:
return {}
return dict(self._store)
But DocumentStore does not implement any sensible __dict__ method. Might it be that the __dict__ method of Document` should rather be:
def __dict__(self):
if not self._store:
return {}
return self._store.getStore()
P.S.: After writing up this issue, I was also able to rewrite my initial code to
doc = connection['your_database']['your_collection']['existing_document_key']
for key, value in doc.getStore().items():
print(f'{key}: {value}')
I would be happy create an MR for the behavior change of __dict__ in Document or, alternatively, to add a paragraph to the README.md or documentation. If there is an even better solution, I'd also be happy to contribute. Just let me know what you prefer!
Environment:
- Python Version: 3.9
- Operating System: Windows
- pyArango Version: 2.,0.1
I expected that the following code will print all key/value pairs from the document with key
existing_document_key:But it causes a
TypeError: 'NoneType' object is not callableexception in thefor key, value in dict(doc).items():line. After some digging, it looks as if the__dict__implementation of thepyArango.document.Documentclass is not correct:But
DocumentStoredoes not implement any sensible__dict__method. Might it be that the__dict__ method ofDocument` should rather be:P.S.: After writing up this issue, I was also able to rewrite my initial code to
I would be happy create an MR for the behavior change of
__dict__inDocumentor, alternatively, to add a paragraph to theREADME.mdor documentation. If there is an even better solution, I'd also be happy to contribute. Just let me know what you prefer!Environment: