summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/soledad_querier.py
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-09-26 13:11:00 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-09-26 13:11:00 -0300
commit1082f233962953c0927b73e7acac2665d420857b (patch)
treee6bd8fef98930e5f1bb18041643da261a606fdc4 /service/pixelated/adapter/soledad_querier.py
parentb4333d2d0955b3f5774bbd1ea97cfdabd5578fd1 (diff)
Fixing tests
Diffstat (limited to 'service/pixelated/adapter/soledad_querier.py')
-rw-r--r--service/pixelated/adapter/soledad_querier.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py
index 179d10f1..7f617767 100644
--- a/service/pixelated/adapter/soledad_querier.py
+++ b/service/pixelated/adapter/soledad_querier.py
@@ -1,6 +1,29 @@
+#
+# Copyright (c) 2014 ThoughtWorks, Inc.
+#
+# Pixelated is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pixelated is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from pixelated.adapter.pixelated_mail import PixelatedMail
+def get_soledad_querier_instance(cls, soledad=None):
+ if not cls.instance:
+ if not soledad:
+ raise Exception("Need a soledad for the first time you call this")
+ cls.instance = SoledadQuerier(soledad)
+ return cls.instance
+
+
class SoledadQuerier:
instance = None
@@ -10,11 +33,7 @@ class SoledadQuerier:
@classmethod
def get_instance(cls, soledad=None):
- if not cls.instance:
- if not soledad:
- raise Exception("Need a soledad for the first time you call this")
- cls.instance = SoledadQuerier(soledad)
- return cls.instance
+ return get_soledad_querier_instance(cls, soledad)
def all_mails(self):
fdocs_chash = [(fdoc, fdoc.content['chash']) for fdoc in self.soledad.get_from_index('by-type', 'flags')]
@@ -48,10 +67,12 @@ class SoledadQuerier:
fdoc = self.soledad.get_from_index('by-type-and-contenthash', 'flags', ident)[0]
hdoc = self.soledad.get_from_index('by-type-and-contenthash', 'head', ident)[0]
bdoc = self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', hdoc.content['body'])[0]
+
return PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self)
def remove_mail(self, mail):
_mail = self.mail(mail.ident)
+ # FIX-ME: Must go through all the part_map phash to delete all the cdocs
self.soledad.delete_doc(_mail.bdoc)
self.soledad.delete_doc(_mail.hdoc)
self.soledad.delete_doc(_mail.fdoc)