[PEAK] A few issues and suggestions

Sergey Schetinin maluke at gmail.com
Mon Nov 3 22:12:22 EST 2008


To make sure undo for .test gets triggered:

tc = TC()
tc.__cells__['test'].layer = tc.__cells__['write'].layer - 1


On Tue, Nov 4, 2008 at 05:09, Sergey Schetinin <maluke at gmail.com> wrote:
> Here's the test case:
>
> class C(Component):
>    x = attr(0)
>    def __init__(self):
>        self.x = 10
>        @on_undo
>        def undo():
>            print 'UNDO'
>
>
> class TC(Component):
>    c = make(C)
>    x = attr(0)
>    y = attr(0)
>
>    @maintain
>    def test(self):
>        if self.x:
>            self.c
>            self.y
>
>    @maintain
>    def write(self):
>        self.y = self.x
>
>
> tc = TC()
>
> @atomically
> def test():
>    tc.x = 1
>    tc.test
>
> print tc.c.x
>
> # prints UNDO \ 0
>
>
>
>
>
> On Tue, Nov 4, 2008 at 04:51, Sergey Schetinin <maluke at gmail.com> wrote:
>>> Thanks for your help identifying and fixing the problems.  I've checked in
>>> fixes, as described here:
>>>
>>> http://svn.eby-sarna.com?rev=2595&view=rev
>>
>> Thanks a lot. However, I see that some problems, that I thought was
>> related to my monkeypatching, didn't go away, what happens in effect
>> is that changes done Component.__init__ get rolled back. I'm working
>> on a test case for this, and I've noticed something I didn't think
>> about before. In the following example __init__ reads data it
>> shouldn't. This isn't a problem normally, but something to keep in
>> mind when writing components' __init__
>>
>> class TC(Component):
>>    y = attr(0)
>>
>>    def __init__(self):
>>        print self.read # 0
>>
>>    @compute
>>    def read(self):
>>        return self.y
>>
>>    @maintain
>>    def write(self):
>>        self.y = 5
>>
>
>
>
> --
> Best Regards,
> Sergey Schetinin
>
> http://s3bk.com/ -- S3 Backup
> http://word-to-html.com/ -- Word to HTML Converter
>



-- 
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter



More information about the PEAK mailing list