[storm] Storm, sqlite, and lists

Tim Penhey tim at penhey.net
Sat Jul 28 07:19:34 BST 2007


On Saturday 28 July 2007 06:13:39 Christopher Armstrong wrote:
> Another interesting technique is using default=AutoReload, so that the
> ID will automatically be loaded from the database when a value is not
> currently available.
> 
> class Account(Storm):
>     __storm_table__ = "account"
> 
>     id = Int(primary=True, default=AutoReload)
> 
> account = store.add(Account())
> print account.id # should be an actual number
> 
> Note that this *doesn't* reload the value from the database on every
> attribute access, so don't worry about that. The default= argument
> only applies when no value is yet available.

Very cool!

Tim



More information about the storm mailing list