Peter Butler wrote:
> I'm just getting to grips with SQLObject so please pardon me if this
> is a question that has been asked before.
>
> Is it possible to defer the insert/update so that the object can be
> validated before the changes are written to the database?
>
> I would like to be able to do the following:
>
> object = MyObject()
> object.field1 = someValue
> object.field2 = someValue
> object.validate() object.save()
>
> With similar logic for objects that already exist in the database.
>
> From looking through the tutorial and source the philosophy seems
> to be to write all object changes to the database as they occur.
> This makes sense to me as it simplifies everything.
You can also set several keys at once using .set(); you might require
that the object be valid for each call to .set(). You can also delay
saves to the database with _lazyUpdate = True, then you can override the
.syncUpdate() method to do validation. Hmm... apparently I haven't
included lazyUpdate in the docs, but it is noted in the News.
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|