Deferring SQLObject database insertion until later
Feb 4, 2005 16:27 · 116 words · 1 minute read
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.