I fill a form fields (in pygtk) from a class instance that contains its attributes with their values.
Once the form is submitted, I get this instance updated with new values.
What is the best way to determine if the form has returned different values (ie: been modified) ? Do I have to make a copy of the object instance before updating it, or return a copy at submit time – then compare each value afterward (seems heavy to me).
Thanks
You will need to have a copy of the data before and after the form has been submitted. The default
__eq__operator will compare all attributes on of class, so you can probably usebefore_form == after_formto see if anything has changed. If you need to know what has changed then you will have to iterate over each attribute.An alternative is to hook into the onchange events of the fields in the form and set a dirty flag if any of them are triggered.