Yes, this answers my question exactly. <br><br>thanks much<br><br>shawn<br><br><div><span class="gmail_quote">On 7/27/07, <b class="gmail_sendername">Jamu Kakar</b> <<a href="mailto:jamshed.kakar@canonical.com">jamshed.kakar@canonical.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Shawn,<br><br>Note: Please include <a href="mailto:storm@lists.canonical.com">
storm@lists.canonical.com</a> in your responses.<br><br>shawn bright wrote:<br>> if i have a new object, and i need to know its id, because it is related<br>> to another object, how do i get that id ? I would need to commit(), then
<br>> re-select it ?<br><br>Nope, you don't need to commit for this case. For the most part, you<br>can just access the attribute and Storm will auto-flush the changes to<br>the database (without actually committing the changes). For example,
<br>the following should work:<br><br>class Person(Storm):<br><br> __storm_table__ = "person"<br><br> id = Int(primary_key=True)<br> name = Unicode(allow_none=False)<br><br> def __init__(self, name):
<br> <a href="http://self.name">self.name</a> = name<br><br>class Account(Storm):<br><br> __storm_table__ = "account"<br><br> id = Int(primary_key=True)<br> owner_id = Int()<br><br> owner = Reference(owner_id,
<a href="http://Person.id">Person.id</a>)<br><br># We'll create an Account object and add it to a store.<br>account = store.add(Account())<br><br># Storm's auto-flushing capability with get an ID, if need be.<br>print
<a href="http://account.id">account.id</a><br><br># The new person object will be automatically added to the store, by<br># way of association with the Account.<br>account.owner = Person("Bob")<br><br># Again, Storm's auto-flushing will get an ID, if necessary.
<br>print <a href="http://account.owner.id">account.owner.id</a><br><br>Does this answer your question?<br><br>Thanks,<br>J.<br></blockquote></div><br>