On Fri, Apr 17, 2009 at 6:35 PM, Lee Connell <[email protected]> wrote:
> Does anyone have any examples on how to use storm-twisted integration within
> a twisted server?
>

tests/twiststorm.py is about all there is now in terms of
documentation - of course this isn't documentation, but all you need
to use is demonstrated there.  External documentation is something
I've been wanting to contribute actually.

I normally use inlineCallbacks around code using DeferredStore etc.,
so a typical function might look like:

@inlineCallbacks
def dostuff():
     store = DeferredStore(database)
     yield store.start()
     foo = Foo()
     yield store.add(foo)
     ...
     bars = yield (yield store.find(Bar, Bar.type==u'chocolate')).all()
     for bar in bars:
        bar.price += 1
     yield store.commit()

You can also use a store pool implementation with a transact API:

@inlineCallbacks
def tx(store):
    foo = yield store.get(Foo, 1)
    ... do stuff (commit/rollback occurs after return)

def cb_pool(pool):
    return pool.transact(tx)

pool = StorePool(database, min, max)
pool.start().addCallback(lambda whatever : cb_pool(pool))


-Drew

-- 
storm mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/storm

Reply via email to