Changes between Version 2 and Version 3 of NewManipulators


Ignore:
Timestamp:
Jul 19, 2006, 7:20:29 PM (18 years ago)
Author:
brantley
Comment:

cosmetic

Legend:

Unmodified
Added
Removed
Modified
  • NewManipulators

    v2 v3  
    11== New Manipulators ==
    2 [''This is section is a lot of explination, to get right to some code scroll down.''][[br]]
     2[''This is section is a lot of explination, to get right to some code scroll down.'']
     3
    34Although validation aware models are great for database integrity, and should be leveraged within the manipulator system, it is still necessary for manipulators to do most of the work.  There are three main steps to the process of taking post data and updating or creating a model object with that data:
    45 1. Gather and convert the post data.
     
    67 3. Apply the data to the object and save, aka do something with the data.
    78
    8 A validation aware model alone cannot complete this task as information needs to be provided that details the sorts of fields that should be used, and processes are needed to convert from string / post data to the pythonic data.  Furthermore many manipulation and form tasks require form fields that do not map directly to a model field, for instance a password changing form that requires a password to be given twice.  This example also illuminates how a form field might map directly to a model field, but may not want to give its direct value to the field.  As in a password, one probably wouldn't want: user.password = data['password'], but rather: user.set_password(data['password']).
     9A validation aware model alone cannot complete this task as information needs to be provided that details the sorts of fields that should be used, and processes are needed to convert from string / post data to the pythonic data.  Furthermore many manipulation and form tasks require form fields that do not map directly to a model field, for instance a password changing form that requires a password to be given twice.  This example also illuminates how a form field might map directly to a model field, but may not want to give its direct value to the field.  As in a password, one probably wouldn't want: {{{user.password = data['password']}}}, but rather: {{{user.set_password(data['password'])}}}.
    910
    1011So we change Manipulators some, and then add model validation.  But we need to make our manipulator system leverage it.  In other words, when our model throws a ValidationError, we need to add it to our errors and then present our form back to the user.  This should be made simple for the developer so that they don't have to create a try/except block every time they want to save an object.
Back to Top