Yes, this answers my question exactly. thanks much
shawn On 7/27/07, Jamu Kakar <[EMAIL PROTECTED]> wrote: > > Hi Shawn, > > Note: Please include [email protected] in your responses. > > shawn bright wrote: > > if i have a new object, and i need to know its id, because it is related > > to another object, how do i get that id ? I would need to commit(), then > > re-select it ? > > Nope, you don't need to commit for this case. For the most part, you > can just access the attribute and Storm will auto-flush the changes to > the database (without actually committing the changes). For example, > the following should work: > > class Person(Storm): > > __storm_table__ = "person" > > id = Int(primary_key=True) > name = Unicode(allow_none=False) > > def __init__(self, name): > self.name = name > > class Account(Storm): > > __storm_table__ = "account" > > id = Int(primary_key=True) > owner_id = Int() > > owner = Reference(owner_id, Person.id) > > # We'll create an Account object and add it to a store. > account = store.add(Account()) > > # Storm's auto-flushing capability with get an ID, if need be. > print account.id > > # The new person object will be automatically added to the store, by > # way of association with the Account. > account.owner = Person("Bob") > > # Again, Storm's auto-flushing will get an ID, if necessary. > print account.owner.id > > Does this answer your question? > > Thanks, > J. >
-- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
