pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

return validated field on fs.sync as a dictionary #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice if fs.validate() would return all "pythonized" fields and
fs.sync() would return all updated fields.

Original issue reported on code.google.com by iElect...@gmail.com on 2 Feb 2009 at 3:34

GoogleCodeExporter commented 9 years ago
Hmm.

Validate doesn't do anything special.  (This isn't formencode.)  You can get 
the submitted, deserialized value with 
fs.fieldname.value.

I could see adding a .changes() method or something, but I don't like shoving 
it into sync.

Original comment by jbel...@gmail.com on 2 Feb 2009 at 3:42

GoogleCodeExporter commented 9 years ago
.changes() would be great.

this is very useful for various reasons, for example sending emails to users 
based on
some database changes.

Original comment by iElect...@gmail.com on 4 Feb 2009 at 10:58

GoogleCodeExporter commented 9 years ago
after further thought I don't see a compelling reason to build this into FA.

you can easily write your own changes method:

def changes(fs):
  return dict((key, value) for key, value in fs.render_fields.items() if value !=
getattr(fs.model, key))

Original comment by jbel...@gmail.com on 6 Feb 2009 at 3:33