Reputation: 95
I'm trying to step through the whole process of form validation in django, using Eclipse/Pydev. I'm getting a totally unexpected result.
parent_form = form_class(request.POST, initial=initial)
debug_type = type(parent_form._errors)
msg = _('created successfully') # <------- Set breakpoint here
Here's what I get from poking around in the console.
debug_type
<type 'NoneType'>
type(parent_form._errors)
<class 'django.forms.util.ErrorDict'>
I don't understand why the two values are different; the first value is what should be "correct".
In the django source, there exists something called parent_form.errors (note the lack of leading underscore before errors) which is a property of parent_form; getting that property runs the bit of code that would cause _errors to go from None to ErrorDict. But I'm not getting parent_form.errors, I'm asking for parent_form._errors.
Could it be that PyDev evaluates parent_form.errors without asking for it? If so why? And why can't I catch this silent evaluation by setting breakpoints in the getter for parent_form.errors?
Upvotes: 1
Views: 182
Reputation: 25362
When you hit a breakpoint and PyDev fills the variables view (where you can see the value of each variable), it'll do a dir() on all the variables in the scope and a getattr() for each of those variables found (that's a bit of a simplification on what the debugger does, but it's close to it)...
So, it can't really guess if some variable would have some side-effect or not... You can try closing the variables view to check if it'll only do that if the variables are actually requested (although it could be that it requests some things even if it's closed, not sure about that).
Upvotes: 2