Hi Phillip,<br><br>I tried a naive <br><br>fitered_records = [r for r in records if "some segment" in <a href="http://r.name">r.name</a>]<br><br>It didn't work :)<br>I get:<br>peak.events.trellis.InputConflict: (Set([]), [])<br>
<br>as for changes, here is the code:<br><br> @trellis.observer<br> def updateView(self):<br> x = len(self.records) # needed to monitor changes<br> if self.sorted_records:<br> self.txt.Clear()<br>
for r in self.sorted_records:<br> self.txt.AppendText(self.fmt.format(r)+"\n") <br><br>if I remove the first line in the method the observer no longer gets triggered. <br>In all cases the only thing that changes are new record being added to the records set.<br>
<br>Peter<br><br><div class="gmail_quote">On Wed, Apr 16, 2008 at 6:19 PM, Phillip J. Eby <<a href="mailto:pje@telecommunity.com">pje@telecommunity.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">At 11:32 AM 4/16/2008 +0300, Peter Damoc wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
<br>
I have an app where I use a trellis.Set to hold some records, a trellis.SortedSet to keep them in order but now I need to filter the records based on some criteria.<br>
<br>
records = trellis.Set()<br>
filtered_records = trellis.???<br>
sorted_records = trellis.SortedSet(data=filtered_records)<br>
<br>
How can I do this?<br>
</blockquote>
<br></div>
In the simple case, you could just write a rule that returns a new set. If you want to be more sophisticated, you can write a rule that adds or deletes records in filtered_records using records.added and records.deleted.<div class="Ih2E3d">
<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Also, if I have an observer that watches over sorted_records, shouldn't it be triggered if a change in the underlying set is made?<br>
</blockquote>
<br></div>
Yes. Of course, by "change" here, it would mean additions or removals from the set, not changes to mutable values associated with those objects. SortedSet is intended for sets of immutable objects at the present time.<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>There is NO FATE, we are the creators.