[storm] data separation

Thomas Hervé thomas at canonical.com
Tue Jan 27 18:48:14 GMT 2009


Le mardi 27 janvier 2009 à 19:30 +0100, Johan Rydberg a écrit :
> I'm experimenting a bit with storm, and for the sake of data separation
> I created three different tables, all sharing the same unique primary
> key.  See the example below.
> 
> First of all, why is foo.state None before the add?  Will store.add(foo)
> also att foo.state and foo.private? I'm under that impression because of
> the tutorial.
> 
> Lastly, is this pattern supposed to work? :)  I'm not very familiar with
> database design.  Can I have two model classes refering to the same
> table?
> 
> 
> from storm.locals import *
> 
> class FooPrivate(object):
>      __storm_table__ = 'foo_private'
>      id = Int(primary=True)
> 
> class FooState(object):
>      __storm_table__ = 'foo_state'
>      id = Int(primary=True)

Your problem is here: you need to have AutoReload by default, ie:

class FooPrivate(object):
     __storm_table__ = 'foo_private'
     id = Int(primary=True, default=AutoReload)

class FooState(object):
     __storm_table__ = 'foo_state'
     id = Int(primary=True, default=AutoReload)

And it should work as expected.

-- 
Thomas




More information about the storm mailing list