Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / af / ace3961e36dd9e54089500e0edbca4d8d3329e
1 Return-Path: <amdragon@mit.edu>\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 24337431FD2\r
6         for <notmuch@notmuchmail.org>; Sun, 13 May 2012 16:36:27 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id loPIorvo0PyR for <notmuch@notmuchmail.org>;\r
16         Sun, 13 May 2012 16:36:25 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
18         [18.7.68.35])\r
19         by olra.theworths.org (Postfix) with ESMTP id EC220431FBF\r
20         for <notmuch@notmuchmail.org>; Sun, 13 May 2012 16:36:23 -0700 (PDT)\r
21 X-AuditID: 12074423-b7fcc6d0000008a8-da-4fb0457774f6\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id EE.F8.02216.77540BF4; Sun, 13 May 2012 19:36:23 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q4DNaLRW009043; \r
27         Sun, 13 May 2012 19:36:22 -0400\r
28 Received: from drake.mit.edu\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4DNaKmL001098\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sun, 13 May 2012 19:36:21 -0400 (EDT)\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1STiKq-0004YP-4d; Sun, 13 May 2012 19:36:20 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v2 3/5] python: Update for changes to\r
41         notmuch_database_get_directory\r
42 Date: Sun, 13 May 2012 19:36:11 -0400\r
43 Message-Id: <1336952173-17422-4-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1336952173-17422-1-git-send-email-amdragon@mit.edu>\r
46 References: <1336939029-13969-1-git-send-email-amdragon@mit.edu>\r
47         <1336952173-17422-1-git-send-email-amdragon@mit.edu>\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsUixG6nrlvuusHfYNIzPYvZrT+YLG60djNa\r
50         NE13trh+cyazxZuV81gdWD0Of13I4jHx/Gk2j1v3X7N7PFt1i9ljy6H3zAGsUVw2Kak5mWWp\r
51         Rfp2CVwZs6dvZym4JVjRfHQucwPjbt4uRk4OCQETiW19N9ghbDGJC/fWs3UxcnEICexjlPi1\r
52         4A4ThLOBUWLn6jZGCOc+k8T97u2sEM4sRol9nb9ZQPrZBDQktu1fzghiiwhIS+y8OxusiFmg\r
53         i1Hi95tmZpCEsECIRNOpE2wgNouAqsTdXfPAbF4BB4l7PzoZIQ6Rl3h6vw8szingKNH34CPY\r
54         gUIC5RIz2q+zTGDkX8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXTC83s0QvNaV0EyM4EF2U\r
55         dzD+Oah0iFGAg1GJh/el6QZ/IdbEsuLK3EOMkhxMSqK8TE5AIb6k/JTKjMTijPii0pzU4kOM\r
56         EhzMSiK86x+u9xfiTUmsrEotyodJSXOwKInzami98xMSSE8sSc1OTS1ILYLJynBwKEnwLnYB\r
57         GipYlJqeWpGWmVOCkGbi4AQZzgM0/AxIDW9xQWJucWY6RP4Uoy7Hn4eLrjEKseTl56VKifPO\r
58         ACkSACnKKM2DmwNLIK8YxYHeEubdC1LFA0w+cJNeAS1hAlrCL7AOZElJIkJKqoGxLrbt74WJ\r
59         s5IevfaQW6iksoyrSuNQr6S89IHXDfqCE+aZ1v1oOfDI8WyN6aGlkf8jb87yfGpjYvWvg/nZ\r
60         FIn/bu0TP76KZV+lWhuea1KgPNPkYnCeW2z3zSUff6WuTFGcGh17f8a6F5fqbL13fF9WPWHZ\r
61         FAb/Z78OJW04Lu1n9uuURaaR6+leJZbijERDLeai4kQA3EUqCfsCAAA=\r
62 Cc: tomi.ollila@iki.fi\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\r
66 List-Id: "Use and development of the notmuch mail system."\r
67         <notmuch.notmuchmail.org>\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
71 List-Post: <mailto:notmuch@notmuchmail.org>\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
75 X-List-Received-Date: Sun, 13 May 2012 23:36:27 -0000\r
76 \r
77 notmuch_database_get_directory now returns\r
78 NOTMUCH_STATUS_READ_ONLY_DATABASE on its own (rather than crashing) so\r
79 the workaround in Database.get_directory is no longer necessary.\r
80 ---\r
81  bindings/python/notmuch/database.py |   19 +++++++++----------\r
82  1 file changed, 9 insertions(+), 10 deletions(-)\r
83 \r
84 diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
85 index 1b1ddc3..797554d 100644\r
86 --- a/bindings/python/notmuch/database.py\r
87 +++ b/bindings/python/notmuch/database.py\r
88 @@ -73,8 +73,8 @@ class Database(object):\r
89  \r
90      """notmuch_database_get_directory"""\r
91      _get_directory = nmlib.notmuch_database_get_directory\r
92 -    _get_directory.argtypes = [NotmuchDatabaseP, c_char_p]\r
93 -    _get_directory.restype = NotmuchDirectoryP\r
94 +    _get_directory.argtypes = [NotmuchDatabaseP, c_char_p, POINTER(NotmuchDirectoryP)]\r
95 +    _get_directory.restype = c_uint\r
96  \r
97      """notmuch_database_get_path"""\r
98      _get_path = nmlib.notmuch_database_get_path\r
99 @@ -359,13 +359,6 @@ class Database(object):\r
100          """\r
101          self._assert_db_is_initialized()\r
102  \r
103 -        # work around libnotmuch calling exit(3), see\r
104 -        # id:20120221002921.8534.57091@thinkbox.jade-hamburg.de\r
105 -        # TODO: remove once this issue is resolved\r
106 -        if self.mode != Database.MODE.READ_WRITE:\r
107 -            raise ReadOnlyDatabaseError('The database has to be opened in '\r
108 -                                        'read-write mode for get_directory')\r
109 -\r
110          # sanity checking if path is valid, and make path absolute\r
111          if path and path[0] == os.sep:\r
112              # we got an absolute path\r
113 @@ -378,7 +371,13 @@ class Database(object):\r
114              #we got a relative path, make it absolute\r
115              abs_dirpath = os.path.abspath(os.path.join(self.get_path(), path))\r
116  \r
117 -        dir_p = Database._get_directory(self._db, _str(path))\r
118 +        dir_p = NotmuchDirectoryP()\r
119 +        status = Database._get_directory(self._db, _str(path), byref(dir_p))\r
120 +\r
121 +        if status != STATUS.SUCCESS:\r
122 +            raise NotmuchError(status)\r
123 +        if not dir_p:\r
124 +            return None\r
125  \r
126          # return the Directory, init it with the absolute path\r
127          return Directory(abs_dirpath, dir_p, self)\r
128 -- \r
129 1.7.10\r
130 \r