[storm] Implementing auto add parent
Eduardo Willians
edujurista at gmail.com
Thu Feb 11 19:19:28 GMT 2010
> So, the underlying problem here is that Storm doesn't know that the
> Session record you've created depends on the Oper record. The
> "self.id = oper.id" statement just looks like an assignment.
>
> You might be able to fix this by using the reference to set self.id:
> self.oper = oper
>
> The reference code will make sure that oper is then flushed first
> In general, the answer is to use references. If you're in a situation
> where that isn't possible, then explicitly using the
> store.add_flush_order() method might help (although that needs a
> store).
SOLVED.
Just using "ReferenceSet( )":
<code>
class Session(object):
__storm_table__ = "financial.session"
id = RawStr(primary=True)
initial = Float()
# Refs
oper = Reference(id, Oper.id)
def __init__(self, root, operator, initial, date_time=None,
add_oper=True):
oper = Oper(root, operator, date_time, add_oper)
self.id = oper.id
self.initial = initial
self._oper_ref = ReferenceSet(self.__class__.id, Oper.id) #
Here is the answer
</code>
Thank you, James
Eduardo Willians
More information about the storm
mailing list