Deferring SQLObject database insertion until later

SQLObject automatically inserts entries in the database as soon as you instantiate them. It also runs updates as soon as you modify attributes. This is not always desirable and eter Butler has a recipe to choose when to insert and update new objects. It’s actually not a bad solution, because the object you’re holding is not truly one of your domain objects. That makes it clearer that something more needs to be done with it. SQLObject could implement this functionality directly with a flag passed to __init__. There is already a flag to defer the updates: just set _lazyUpdate = True on the object, then you need to run syncUpdate or sync to save the data.

One thought on “Deferring SQLObject database insertion until later”

Comments are closed.