arsenal-devel team mailing list archive
-
arsenal-devel team
-
Mailing list archive
-
Message #00078
Re: Attachments filtering
On Wed, Jul 21, 2010 at 05:09:16AM +0500, Kamran Riaz Khan wrote:
> Onto the proof of concept branch, lpltk's Attachments class has the
> additional benefit of using yield generators in order to process large
> sets of attachments. IIUC, while your filtered_attachments has the
> benefit of providing cleaner interface for filtering it nullifies the
> generator benefits by filtering all the attachments at once instead of
> relying on yield.
>
> In other words, I think:
>
> def __iter__(self):
> for attachment in self._attachments:
>
> # this is a more suitable place for checking
> # attachment and deciding whether or not to yield it
> # based on filters
>
> yield Attachment(self.__tkbug, attachment)
Cool. So something like this:
def __iter__(self):
self.__fetch_if_needed()
for attachment in self.__attachments:
a = Attachment(self.__tkbug, attachment)
for f, params in self.__filters.items():
if not f(a, params):
continue
yield a
However, I do like that filtered_attachments() caches the filtered list
in memory (and in my newest branch, resets if a new filter is applied).
> If no one else takes this up, I'll try uploading a branch with this
> implementation after I get done with send_upstream.cgi and
> send-attachments-upstream.
Sure, would love to see your shot at it, this could probably be done
smarter.
Let me know what changes you're planning to send_upstream.cgi -- I've
been hacking on it as well so we should coordinate what we do.
Bryce
Follow ups
References