booby
booby copied to clipboard
__repr__() causes maximum recursion depth error
The repr() function of self-referencing Models and Models referencing to other Models which reference to the first one, cause an "maximum recursion depth" error. Because the repr() function is called for every referenced model over and over again. For example if you have something like this:
class Address(Model):
street = String()
persons = Collection(Person)
class Person(Model):
name = String()
addresses = Collection(Address)
And repr() is called on an instance of one of the models, it causes the "maximum recursion depth" error.
Same happens if I try to use the class as a static field of itself:
class Division(Model):
name = String()
id = Integer
Division.parent = Division()
Personally, I would remove the __repr__()
functions and use the built-in instead, in most cases you do not need this output when __repr__()
is called.
Is there a chance that you are going to merge the corresponding pull request?
I still haven't found a good reason for keeping those custom __repr__()
functions..
Bump