--- /dev/null
+Return-Path: <glasse@cs.rpi.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 3E774429E43\r
+ for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:06:01 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.54\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3,\r
+ RCVD_IN_SORBS_WEB=0.614] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id AGWL35BsDslV for <notmuch@notmuchmail.org>;\r
+ Wed, 15 Feb 2012 14:05:57 -0800 (PST)\r
+Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu\r
+ [128.113.126.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS\r
+ id 4865F431E84 for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:05:57 -0800\r
+ (PST)\r
+X-Hash:\r
+ S|a5576c7a0879cdcb947f4f187d2cb881f84fe767|3108d4ff51f659d951563fa092480fc6\r
+X-Countries: Cameroon, United States\r
+X-SMTP-From: accepted <glasse@cs.rpi.edu> [195.24.209.20] [195.24.209.20]\r
+ (localhost) {Cameroon}\r
+DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from\r
+ :to:cc:subject:date:message-id:in-reply-to:references; s=\r
+ default; i=glasse@cs.rpi.edu; t=1329343555; x=1329948355; l=6302;\r
+ bh=xqCkkenyPqaR9+qkgrhnSOEGp8c=; b=E28AwTlbi+ZvfI6i/WJgSSd\r
+ 72/sQMaeuBwnOkH8K8DYEAJb75uImAOaBOrTAXNBka7xQoE2E6X6dnujDSCiucSF\r
+ +6tfHj1+b9jFt8IICMX1GvjIJOC4gcGnmbGO8Iuo93HwkQitBzJqgpPecb3heRFR\r
+ 88ZyxZ4cBo+wo6x0nkyA=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc\r
+ :subject:date:message-id:in-reply-to:references; q=dns; s=\r
+ default; b=Xmcurs/GUda4Y5HviM8tJTMfcm4qcwtMVwxRTv+hksoFexm4N9Ai7\r
+ 0CtFflAdbYASlcgG/SK82SeklNukDlLjprgdbW8sCkKiIbq8RmDZ83+3FbD6z/Ea\r
+ 9IckCs1CRKzPQcZkJrZ57TXBAHCWW7o3v4pCKJHgJpKUVoVLSpXbek=\r
+X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00\r
+X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit\r
+ 15)\r
+Authentication-Results: cliffclavin.cs.rpi.edu;\r
+ DKIM=neutral (none) header.from=glasse@cs.rpi.edu;\r
+ SPF=neutral (mfrom;\r
+ Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu\r
+X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FM5RID008763 Auth:glasse\r
+X-Virus-Scanned-By: cliffclavin.cs.rpi.edu\r
+Received: from localhost ([195.24.209.20]) (authenticated bits=0)\r
+ by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FM5RID008763\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);\r
+ Wed, 15 Feb 2012 17:05:40 -0500 (EST)\r
+ (envelope-from glasse@cs.rpi.edu)\r
+From: Ethan Glasser-Camp <glasse@cs.rpi.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 03/13] Introduce mailstore in the python bindings\r
+Date: Wed, 15 Feb 2012 17:01:56 -0500\r
+Message-Id: <1329343326-16410-4-git-send-email-glasse@cs.rpi.edu>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
+References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
+X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25\r
+Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 15 Feb 2012 22:06:01 -0000\r
+\r
+From: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+\r
+\r
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+ bindings/python/notmuch/database.py | 31 +++++++++++++++++---------\r
+ bindings/python/notmuch/globals.py | 3 ++\r
+ bindings/python/notmuch/mailstore.py | 38 ++++++++++++++++++++++++++++++++++\r
+ 3 files changed, 61 insertions(+), 11 deletions(-)\r
+ create mode 100644 bindings/python/notmuch/mailstore.py\r
+\r
+diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+index 36b65ec..638ade3 100644\r
+--- a/bindings/python/notmuch/database.py\r
++++ b/bindings/python/notmuch/database.py\r
+@@ -23,7 +23,9 @@ from ctypes import c_char_p, c_void_p, c_uint, c_long, byref, POINTER\r
+ from notmuch.globals import (nmlib, STATUS, NotmuchError, NotInitializedError,\r
+ NullPointerError, Enum, _str,\r
+ NotmuchDatabaseP, NotmuchDirectoryP, NotmuchMessageP, NotmuchTagsP,\r
+- NotmuchQueryP, NotmuchMessagesP, NotmuchThreadsP, NotmuchFilenamesP)\r
++ NotmuchQueryP, NotmuchMessagesP, NotmuchThreadsP, NotmuchFilenamesP,\r
++ NotmuchMailstoreP)\r
++from notmuch.mailstore import Mailstore\r
+ from notmuch.thread import Threads\r
+ from notmuch.message import Messages, Message\r
+ from notmuch.tag import Tags\r
+@@ -78,7 +80,7 @@ class Database(object):\r
+ \r
+ """notmuch_database_open"""\r
+ _open = nmlib.notmuch_database_open\r
+- _open.argtypes = [c_char_p, c_uint]\r
++ _open.argtypes = [NotmuchMailstoreP, c_char_p, c_uint]\r
+ _open.restype = NotmuchDatabaseP\r
+ \r
+ """notmuch_database_upgrade"""\r
+@@ -105,11 +107,13 @@ class Database(object):\r
+ \r
+ """notmuch_database_create"""\r
+ _create = nmlib.notmuch_database_create\r
+- _create.argtypes = [c_char_p]\r
++ _create.argtypes = [NotmuchMailstoreP, c_char_p]\r
+ _create.restype = NotmuchDatabaseP\r
+ \r
+- def __init__(self, path=None, create=False, mode=0):\r
+- """If *path* is `None`, we will try to read a users notmuch\r
++ def __init__(self, mailstore=None, path=None, create=False, mode=0):\r
++ """If *mailstore* is `None`, we will just use 'maildir'.\r
++\r
++ If *path* is `None`, we will try to read a users notmuch\r
+ configuration and use his configured database. The location of the\r
+ configuration file can be specified through the environment variable\r
+ *NOTMUCH_CONFIG*, falling back to the default `~/.notmuch-config`.\r
+@@ -130,6 +134,9 @@ class Database(object):\r
+ failure.\r
+ """\r
+ self._db = None\r
++ if mailstore == None:\r
++ mailstore = Mailstore('maildir')\r
++\r
+ if path is None:\r
+ # no path specified. use a user's default database\r
+ if Database._std_db_path is None:\r
+@@ -138,16 +145,16 @@ class Database(object):\r
+ path = Database._std_db_path\r
+ \r
+ if create == False:\r
+- self.open(path, mode)\r
++ self.open(mailstore, path, mode)\r
+ else:\r
+- self.create(path)\r
++ self.create(mailstore, path)\r
+ \r
+ def _assert_db_is_initialized(self):\r
+ """Raises :exc:`NotInitializedError` if self._db is `None`"""\r
+ if self._db is None:\r
+ raise NotInitializedError()\r
+ \r
+- def create(self, path):\r
++ def create(self, mailstore, path):\r
+ """Creates a new notmuch database\r
+ \r
+ This function is used by __init__() and usually does not need\r
+@@ -167,14 +174,15 @@ class Database(object):\r
+ raise NotmuchError(message="Cannot create db, this Database() "\r
+ "already has an open one.")\r
+ \r
+- res = Database._create(_str(path), Database.MODE.READ_WRITE)\r
++ mailstore = mailstore._mailstore\r
++ res = Database._create(mailstore, _str(path), Database.MODE.READ_WRITE)\r
+ \r
+ if not res:\r
+ raise NotmuchError(\r
+ message="Could not create the specified database")\r
+ self._db = res\r
+ \r
+- def open(self, path, mode=0):\r
++ def open(self, mailstore, path, mode=0):\r
+ """Opens an existing database\r
+ \r
+ This function is used by __init__() and usually does not need\r
+@@ -187,7 +195,8 @@ class Database(object):\r
+ :exception: Raises :exc:`NotmuchError` in case of any failure\r
+ (possibly after printing an error message on stderr).\r
+ """\r
+- res = Database._open(_str(path), mode)\r
++ mailstore = mailstore._mailstore # unwrap mailstore\r
++ res = Database._open(mailstore, _str(path), mode)\r
+ \r
+ if not res:\r
+ raise NotmuchError(message="Could not open the specified database")\r
+diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
+index 4138460..5f01dce 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -228,6 +228,9 @@ class NotmuchDatabaseS(Structure):\r
+ pass\r
+ NotmuchDatabaseP = POINTER(NotmuchDatabaseS)\r
+ \r
++class NotmuchMailstoreS(Structure):\r
++ pass\r
++NotmuchMailstoreP = POINTER(NotmuchMailstoreS)\r
+ \r
+ class NotmuchQueryS(Structure):\r
+ pass\r
+diff --git a/bindings/python/notmuch/mailstore.py b/bindings/python/notmuch/mailstore.py\r
+new file mode 100644\r
+index 0000000..315ea70\r
+--- /dev/null\r
++++ b/bindings/python/notmuch/mailstore.py\r
+@@ -0,0 +1,38 @@\r
++"""\r
++This file is part of notmuch.\r
++\r
++Notmuch is free software: you can redistribute it and/or modify it\r
++under the terms of the GNU General Public License as published by the\r
++Free Software Foundation, either version 3 of the License, or (at your\r
++option) any later version.\r
++\r
++Notmuch is distributed in the hope that it will be useful, but WITHOUT\r
++ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\r
++for more details.\r
++\r
++You should have received a copy of the GNU General Public License\r
++along with notmuch. If not, see <http://www.gnu.org/licenses/>.\r
++\r
++Copyright 2012 Ethan Glasser-Camp <ethan@betacantrips.com>'\r
++"""\r
++\r
++# This is all kind of cargo-culted from database.py. I hope someone\r
++# else takes a good look at this!\r
++\r
++import os\r
++from ctypes import c_char_p, c_void_p, c_uint, c_long, byref, POINTER\r
++from notmuch.globals import (nmlib, STATUS, NotmuchError, NotInitializedError,\r
++ NullPointerError, Enum, _str,\r
++ NotmuchDatabaseP, NotmuchDirectoryP, NotmuchMessageP, NotmuchTagsP,\r
++ NotmuchQueryP, NotmuchMessagesP, NotmuchThreadsP, NotmuchFilenamesP,\r
++ NotmuchMailstoreP,)\r
++\r
++class Mailstore(object):\r
++ """The :class:`Mailstore` represents "where the mail lives"."""\r
++ _get_by_name = nmlib.notmuch_mailstore_get_by_name\r
++ _get_by_name.argtypes = [c_char_p]\r
++ _get_by_name.restype = NotmuchMailstoreP\r
++\r
++ def __init__(self, type=None, path=None):\r
++ self._mailstore = self._get_by_name(type)\r
+-- \r
+1.7.5.4\r
+\r