unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Brian May <brian@microcomaustralia.com.au>
To: Patrick Totzke <patricktotzke@googlemail.com>
Cc: notmuch <notmuch@notmuchmail.org>
Subject: Re: [python] get all messages of a thread
Date: Wed, 1 Jun 2011 15:35:35 +1000	[thread overview]
Message-ID: <BANLkTikEJ9dJ5kLg2QJQ+egHg2sh7S1wiA@mail.gmail.com> (raw)
In-Reply-To: <1306588052-sup-9838@brick>

[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]

On 28 May 2011 23:18, Patrick Totzke <patricktotzke@googlemail.com> wrote:

>    if r: #because we cant iterate on NoneType
>

I don't understand why, but this line sets r._msgs to None. So it crashes,
because it has no message ids to look for.

If you change it to

if r is not None:

... then it works for me.

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:

      .. note:: As this iterates over the messages, we will not be able to=
               iterate over them again! So this will fail::

                 #THIS FAILS
                 msgs = Database().create_query('').search_message()
                 if len(msgs) > 0:              #this 'exhausts' msgs
                     # next line raises
NotmuchError(STATUS.NOT_INITIALIZED)!!!
                     for msg in msgs: print msg

               Most of the time, using the
               :meth:`Query.count_messages` is therefore more
               appropriate (and much faster). While not guaranteeing
               that it will return the exact same number than len(),
               in my tests it effectively always did so.



-- 
Brian May <brian@microcomaustralia.com.au>

[-- Attachment #2: Type: text/html, Size: 1920 bytes --]

  parent reply	other threads:[~2011-06-01  5:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-28 13:18 [python] get all messages of a thread Patrick Totzke
2011-05-31 23:48 ` Carl Worth
2011-06-01  5:35 ` Brian May [this message]
2011-06-02  7:05   ` Sebastian Spaeth
2011-06-02  9:43     ` Brian May
2011-06-02 14:20       ` Sebastian Spaeth
2011-06-02 14:37         ` Sebastian Spaeth
2011-06-02 14:38         ` Austin Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTikEJ9dJ5kLg2QJQ+egHg2sh7S1wiA@mail.gmail.com \
    --to=brian@microcomaustralia.com.au \
    --cc=notmuch@notmuchmail.org \
    --cc=patricktotzke@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).