akaihola wrote:
Ok, I'll take a look at the _pre_save() mechanism. By the way, isn't
that one of the things changing in magic-removal branch?
Yes, it goes away. Instead one would be able to override save() and do
everything in it.
I still wonder about the default values question though.
I tried to create a Django object in an interactive Python shell, and
the fields are indeed filled with default values. So somewhere in the
form/manipulator mechanism there are unnecessary checks which prevent
this from happening and raise errors instead.
Indeed, default values are set upon model object creation. This is good
:-). But a manipulator doesn't prevent them in any way. What happens is
that a manipulator checks the values that come from the web, and not the
default ones inside it.
To make it work as expected you do something like:
m=someitems.AddManipulator() # or someitems.ChangeManipulator(id)
data=m.flatten_data() # this returns object's data suitable for
rendering on the web including default values
f=formfields.FormWrapper(m, data, {}) # form gets values from this
'data' parameter
And then you form will be prefilled. And you can feed these values to
the saving manipulator on POST
Now that makes me wonder why data is passed to a form separately from
manipulator which has it anyway...