コード例 #1
0
ファイル: test_relations.py プロジェクト: anderslime/smache
def setup_module(module):
    global smache, f, h

    DummyA.unsubscribe_all()
    DummyB.unsubscribe_all()
    DummyC.unsubscribe_all()

    smache = Smache(scheduler=InProcessScheduler(), write_through=False)

    @smache.relations((DummyB, lambda b: DummyC.find('30')))
    @smache.computed(DummyA, DummyC, Raw, Raw)
    def f(a, dummyc, c, d):
        b = DummyB.find('2')
        return a.value * b.value

    @smache.relations((DummyB, lambda b: [DummyA.find('1'), DummyA.find('2')]))
    @smache.computed(DummyA, Raw, Raw)
    def h(a, c, d):
        b = DummyB.find('2')
        return a.value * b.value