[PATCH 1/9] lib: read "property" terms from messages.
[notmuch-archives.git] / 3e / cf346faee42d28cf32635b7a7ae96a4bb33696
1 Return-Path: <brian@microcomaustralia.com.au>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 95727431FD0\r
6         for <notmuch@notmuchmail.org>; Tue, 31 May 2011 22:35:39 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id VUTZKYIGCkoc for <notmuch@notmuchmail.org>;\r
17         Tue, 31 May 2011 22:35:37 -0700 (PDT)\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 4B4AB431FB6\r
22         for <notmuch@notmuchmail.org>; Tue, 31 May 2011 22:35:37 -0700 (PDT)\r
23 Received: by bwg12 with SMTP id 12so4795130bwg.26\r
24         for <notmuch@notmuchmail.org>; Tue, 31 May 2011 22:35:35 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=microcomaustralia.com.au; s=google;\r
27         h=domainkey-signature:mime-version:x-originating-ip:in-reply-to\r
28         :references:date:message-id:subject:from:to:cc:content-type;\r
29         bh=pZHC8uqvQZee5XReK4U8LuXTkm+Rz8mOwycGQf+YVbU=;\r
30         b=W5vQ+2KisPe7G7EMCuJm3mFuoJWQ9D7kkY6qPZSyDxcHAIpoRTcPCmnZ4R5YoyKm8Q\r
31         lzTbMOioVtIeDeW8q3loZGacDxfS6m63qcp3V6xuogxCAPX/P9pd36MJ0AAx4Xof6mSG\r
32         wUw1QEBRFXf5TipBA68H9O/Ez6Bayvfa09FoI=\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=microcomaustralia.com.au;\r
34  s=google;      h=mime-version:x-originating-ip:in-reply-to:references:date\r
35         :message-id:subject:from:to:cc:content-type;\r
36         b=bnwzHsdSUwplVXB5Xy/Sjo0xx7fK9olrQDLnGSg3uPXjZQ4EdLV1Q/nqNU4WRAFx0U\r
37         3UZtOykLORTH7eI0HRP3UKQoujkkfXREdJjuRthNytoVlCYcRm6O0MxIz6cIUZvb2i/C\r
38         aYeN4KvDUn3hBeNFbHesW3bVLVd8N8FzpuBtA=\r
39 MIME-Version: 1.0\r
40 Received: by 10.204.172.66 with SMTP id k2mr6239203bkz.125.1306906535558; Tue,\r
41         31 May 2011 22:35:35 -0700 (PDT)\r
42 Received: by 10.204.82.147 with HTTP; Tue, 31 May 2011 22:35:35 -0700 (PDT)\r
43 X-Originating-IP: [128.250.103.228]\r
44 In-Reply-To: <1306588052-sup-9838@brick>\r
45 References: <1306588052-sup-9838@brick>\r
46 Date: Wed, 1 Jun 2011 15:35:35 +1000\r
47 Message-ID: <BANLkTikEJ9dJ5kLg2QJQ+egHg2sh7S1wiA@mail.gmail.com>\r
48 Subject: Re: [python] get all messages of a thread\r
49 From: Brian May <brian@microcomaustralia.com.au>\r
50 To: Patrick Totzke <patricktotzke@googlemail.com>\r
51 Content-Type: multipart/alternative; boundary=bcaec52c5c8dce7d8804a49fe3bc\r
52 Cc: notmuch <notmuch@notmuchmail.org>\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Wed, 01 Jun 2011 05:35:39 -0000\r
66 \r
67 --bcaec52c5c8dce7d8804a49fe3bc\r
68 Content-Type: text/plain; charset=ISO-8859-1\r
69 \r
70 On 28 May 2011 23:18, Patrick Totzke <patricktotzke@googlemail.com> wrote:\r
71 \r
72 >    if r: #because we cant iterate on NoneType\r
73 >\r
74 \r
75 I don't understand why, but this line sets r._msgs to None. So it crashes,\r
76 because it has no message ids to look for.\r
77 \r
78 If you change it to\r
79 \r
80 if r is not None:\r
81 \r
82 ... then it works for me.\r
83 \r
84 Oh, I see, for your code, there is a implied call to __len__, and the\r
85 __len__ function is completely broken for the reasons described in the\r
86 documentation:\r
87 \r
88       .. note:: As this iterates over the messages, we will not be able to=\r
89                iterate over them again! So this will fail::\r
90 \r
91                  #THIS FAILS\r
92                  msgs = Database().create_query('').search_message()\r
93                  if len(msgs) > 0:              #this 'exhausts' msgs\r
94                      # next line raises\r
95 NotmuchError(STATUS.NOT_INITIALIZED)!!!\r
96                      for msg in msgs: print msg\r
97 \r
98                Most of the time, using the\r
99                :meth:`Query.count_messages` is therefore more\r
100                appropriate (and much faster). While not guaranteeing\r
101                that it will return the exact same number than len(),\r
102                in my tests it effectively always did so.\r
103 \r
104 \r
105 \r
106 -- \r
107 Brian May <brian@microcomaustralia.com.au>\r
108 \r
109 --bcaec52c5c8dce7d8804a49fe3bc\r
110 Content-Type: text/html; charset=ISO-8859-1\r
111 Content-Transfer-Encoding: quoted-printable\r
112 \r
113 <div class=3D"gmail_quote">On 28 May 2011 23:18, Patrick Totzke <span dir=\r
114 =3D"ltr">&lt;<a href=3D"mailto:patricktotzke@googlemail.com">patricktotzke@=\r
115 googlemail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" s=\r
116 tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">\r
117 =A0 =A0if r: #because we cant iterate on NoneType<br></blockquote><div><br>=\r
118 </div><div>I don&#39;t understand why, but this line sets r._msgs to None. =\r
119 So it crashes, because it has no message ids to look for.</div><div><br></d=\r
120 iv>\r
121 <div>If you change it to</div><div><br></div><div>if r is not None:</div><d=\r
122 iv><br></div><div>... then it works for me.=A0</div><div><br></div><div>Oh,=\r
123  I see, for your code, there is a implied call to __len__, and the __len__ =\r
124 function is completely broken for the reasons described in the documentatio=\r
125 n:</div>\r
126 <div><br></div><div><div>=A0 =A0 =A0 .. note:: As this iterates over the me=\r
127 ssages, we will not be able to=3D</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=\r
128 iterate over them again! So this will fail::</div><div><br></div><div>=A0 =\r
129 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0#THIS FAILS</div>\r
130 <div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0msgs =3D Database().create_query(&#=\r
131 39;&#39;).search_message()</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if =\r
132 len(msgs) &gt; 0: =A0 =A0 =A0 =A0 =A0 =A0 =A0#this &#39;exhausts&#39; msgs<=\r
133 /div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0# next line raises Not=\r
134 muchError(STATUS.NOT_INITIALIZED)!!!</div>\r
135 <div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for msg in msgs: print msg<=\r
136 /div><div><br></div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Most of the time, u=\r
137 sing the</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:meth:`Query.count_messag=\r
138 es` is therefore more</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0appropriate =\r
139 (and much faster). While not guaranteeing</div>\r
140 <div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0that it will return the exact same numb=\r
141 er than len(),</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0in my tests it effe=\r
142 ctively always did so.</div></div><div><br></div><div><br></div><div><br></=\r
143 div></div>-- <br>Brian May &lt;<a href=3D"mailto:brian@microcomaustralia.co=\r
144 m.au">brian@microcomaustralia.com.au</a>&gt;<br>\r
145 \r
146 \r
147 --bcaec52c5c8dce7d8804a49fe3bc--\r