[PEAK] Re: trellis.Set.discard

Sergey Schetinin maluke at gmail.com
Thu Oct 30 22:06:56 EDT 2008

I was away for some time, but when I started working on my library
again, I found out that my workaround for @make inside @compute has an
effect of sometimes breaking the dependency chain, my attempts to make
sure that doesn't happen have failed, so I wonder if any decision was
made on how to fix that?

Just in case, my workaround looks like this:

from peak.rules import around
from peak.events.stm import Link
from peak.events.trellis import ConstantMixin

def make_cell(next_method, self, typ, ob, name):
    if ctrl.readonly:
        cell = side_txn(next_method, self, typ, ob, name)
        if not isinstance(cell, ConstantMixin):
            Link(cell, ctrl.current_listener)
        return cell
        return next_method(self, typ, ob, name)

On Wed, Oct 22, 2008 at 03:22, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 08:50 PM 10/21/2008 -0400, Phillip J. Eby wrote:
>> Hm.  ISTM that this is a bug in Component creation, in that it should push
>> and restore read-onlyness.  The make() should be idempotent with respect to
>> the @compute rule.
> Unfortunately, it's not *quite* that simple.  What's really needed is to
> allow changes to cells even during "read-only" periods, as long as they are
> "new".
> It's the precise definition of "new" that eludes me...  I suppose we could
> keep a set of "cells created" within a given "transaction", and clear it
> upon commit.  Component creation could then push and pop this set, instead
> of pushing and popping read-onlyness.
> Unfortunately, such a set could complicate garbage collection, unless it
> used weak references.  I suppose that's probably an acceptable solution,
> though.
> Also, we probably don't want to consider cells created outside of Component
> creation to be "new", so the "cells created" set could perhaps be None
> during the main transaction body.
> I'm thinking something like ctrl.new_cell(cell) that either registers the
> cell or does nothing, depending on whether the "cells created" set is None
> or not.  Then changed() would check if the changed cell is in the set in the
> readonly case.

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