[python] get all messages of a thread
Sebastian Spaeth
Sebastian at SSpaeth.de
Thu Jun 2 00:05:29 PDT 2011
On Wed, 1 Jun 2011 15:35:35 +1000, Brian May wrote:
> Oh, I see, for your code, there is a implied call to __len__, and the
> __len__ function is completely broken for the reasons described in the
> documentation:
It seems to have been a bad idea to implement __len__ at all for the
Messsages() construct in the python bindings, and I wonder if I should
remove it.
On the other hand, it seems that list(Messages()) implicitely calls
len(), or so it seems from the error that we get when trying to list() a
messages object.
An alternative is to implement len() as a call to count_messages() which
has for me so far always returned the correct number of messages without
using up the iterator. However, the xapian docs explicitely state that
it does not guarantee that the count will be correct, so len() might
return a wrong message size (potentially).
What would be the best way to solve this (besides fixing the C api to
allow to reset the iterator ;-) ?)
I could implement a custom .as_list() function that returns the
Messages() object as a list that is guaranteed to be stable, by copying
out the Message() objects into a list.
Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110602/7c0dd31e/attachment.pgp>
More information about the notmuch
mailing list