allow partial object updates with manipulators
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
currently the manipulators that are created from model modules (ChangeManipuator and AddManipulator) expects all fields of an object in the new_data dict. This is a bit cumbersome if somebody want's to put up a form that only should edit some fields of an object. The validation code will barf about every missing required field and the html2python conversion and data saving will require all data to be there.
An idea that came up on IRC was to give the ChangeManipulator constructor an optional parameter "only_fields" that receives a list of fieldnames that should be worked on in the manipulator. The ChangeManipulator already reads in the original object (and stores it as Manipulator.original_object internally) and so could use the "only_fields" list as a guide to what fields of the original_object should be overwritten with data from new_data.
Additionally the Manipulator would have to keep only the fields named in the "only_fields" list in it's internal fields dictionary so that the validation code and the html2python conversion only work with those fields.
With this change it would be possible to build a form with the standard ChangeManipulator code for situations where only part of the object should be edited - an example would be a user profile page that will allow the user only to edit the first_name, last_name and email fields.