-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meaningful reference errors #28
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't try it myself but looks reasonable.
self.__parent_ref_field_name, | ||
) | ||
error += ') has been deleted.' | ||
raise DoesNotExist(error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add the extra data as exception attributes? At some point we would want to inspect the parent object and parsing error message is not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this, we should start with doing it in the upstream version so that we have a consistent interface. A more informative message on the same exception is good. Raising what would essentially amount to a different exception is not good.
@@ -103,9 +104,12 @@ def __get__(self, instance, owner): | |||
value = self.default() if callable(self.default) else self.default | |||
else: | |||
value = self.to_python(db_value) | |||
if isinstance(value, DocumentProxy): | |||
value._set_parent_ref(instance, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to avoid holding onto the parent instance as this might cause memory leaks. Store just the class (name or reference), and the instance pk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty cool, I'm willing to give it a shot. I agree with V that ideally we'd just store the class name/reference and the ID of the parent instance.
It's been painful trying to figure out which references are broken.
This PR needs more testing, but what do you think? (Feel free to take this PR over)