Skip to content

Custom document_class not being returned #476

Answered by msiemens
markbrai asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @markbrai, I think I understand this issue: You're adding the document_class attribute to the TinyDB class instead of assigning it to the Table class. You can check this by trying to see the document_class value before trying to change it:

>>> print(TinyDB.document_class)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'TinyDB' has no attribute 'document_class'

As you can see, the TinyDB class has no attribute called document_class. But when you try to assign it, Python will not throw an error but instead create a new attribute for this class. Instead, try setting the property like this:

TinyDB.table_class.document_class = MyDocument

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by markbrai
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants