[PEAK] How do I extract a subset?

Peter Damoc pdamoc at gmail.com
Thu Apr 17 11:51:33 EDT 2008


Thank you Phillip,
now it is all clearer.


On Thu, Apr 17, 2008 at 6:27 PM, Phillip J. Eby <pje at telecommunity.com>
wrote:

> At 09:23 AM 4/17/2008 +0300, Peter Damoc wrote:
>
> >    @trellis.observer
> >    def updateView(self):
> >        x = len(self.records) # needed to monitor changes
> >        self.filtered_records = [x for x in self.records]
> >
>
> You can't modify trellis data in an observer.  Move this line to a rule of
> its own, and change it to:
>
>    @trellis.rule
>    def do_filtering(self):
>        self.filtered_records.clear()
>        self.filtered_records.update(x for x in self.records if x...)
>
> This way, the same set object will be updated in-place.  Your observer
> should now check 'self.sorted_records.changes' instead of
> 'len(self.records)' to ensure it's triggered when a change occurs.
>
> Meanwhile, the reason that you're getting a conflict is because you are
> assigning different values to the filtered_records attribute in two places
> during the same calculation.
>
>


-- 
There is NO FATE, we are the creators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20080417/67b11692/attachment.html


More information about the PEAK mailing list