[PEAK] trellis question

nicky van foreest vanforeest at gmail.com
Sat Jul 16 17:33:27 EDT 2011


Hi,

In trying to understand the trellis code I made the following simple example:

from peak.events import trellis

class H(trellis.Component):
    trellis.attrs(
        a = 0,
    )


class Sum(trellis.Component):
    trellis.maintain.attrs(
        tot = lambda self: sum(h.a for h in self.h),
    )

    def __init__(self, h):
        self.h = h

L = []
for i in range(9):
    h = H()
    h.a = i
    L.append(h)

s = Sum(L)
print s.tot

I wonder how trellis finds out that Sum.tot needs h.a for all the h's
in the list. How does it know, for instance, that h.a in the list
comprension sum( h.a for h in self.h) corresponds to a Cell? (Is
actually h.a stored/corresponds to a Cell?)

Thanks in advance.

Nicky


More information about the PEAK mailing list