trellis question

nicky van foreest <[email protected]> Sat, 16 Jul 2011 23:33:27 +0200
Newsgroups gmane.comp.python.peak
Message-ID <CAK_GA2FCNkAdVgfe9Q-FO8jGjL9Ug5sgHpnReyNeHsojwitSXg@mail.gmail.com>
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