This applies for the current Django trunk. Looks like I don't
understand Django code or there is one unthought use case in
manipulators: When you are updating only a partial set of object fields
in save(), save() fails.

Steps to reproduce

1. Create a change manipulator for an object
2. Update only subset of all fields (new_data doesn't contain all
fields in the object)

---> Object save fails since Manipulator.save() doesn't correctly fetch
existing data for fields which are not being updated. I am not sure
what self.follow() and self.auto_add_now code should do below, but that
code path is taken always (self.follow[attributename] = True by
default) and self.change is being ignored, thus existing data is not
fetched. Is this correct behavior or am I using manipulators somehow
wrong?

81          def save(self, new_data):
82              # TODO: big cleanup when core fields go -> use recursive
manipulators.
83              params = {}
84              for f in self.opts.fields:
85                  # Fields with auto_now_add should keep their original
value in the change stage.
86                  auto_now_add = self.change and getattr(f,
'auto_now_add', False)
87                  if self.follow.get(f.name, None) and not auto_now_add:
88                      param = f.get_manipulator_new_data(new_data)
89                  else:
90                      if self.change:
91                          param = getattr(self.original_object,
f.attname)
92                      else:
93                          param = f.get_default()
94                  params[f.attname] = param


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to