summaryrefslogtreecommitdiffstats
path: root/lib/mongo.py
diff options
context:
space:
mode:
authorPierre-Yves Chibon <pingou@pingoured.fr>2012-03-23 18:47:46 +0100
committerPierre-Yves Chibon <pingou@pingoured.fr>2012-03-23 18:47:46 +0100
commit701f5631f04d0420456bd47f864fc238b624ed82 (patch)
tree43a28b8a114cc70596339305c03eda73112b3572 /lib/mongo.py
parenta31b70856bdf9b3f6c7f125e945c6c7fe7d26f8d (diff)
downloadhyperkitty-701f5631f04d0420456bd47f864fc238b624ed82.tar.gz
hyperkitty-701f5631f04d0420456bd47f864fc238b624ed82.tar.xz
hyperkitty-701f5631f04d0420456bd47f864fc238b624ed82.zip
Use int() on the identifier and return nothing if there is nothing to return
Diffstat (limited to 'lib/mongo.py')
-rw-r--r--lib/mongo.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/mongo.py b/lib/mongo.py
index c3f2fab..0c4c71e 100644
--- a/lib/mongo.py
+++ b/lib/mongo.py
@@ -42,7 +42,7 @@ def _tree_to_list(tree, mailid, level, thread_list):
def get_thread_list(table, threadid):
db = connection[table]
- thread = list(db.mails.find({'ThreadID': threadid},
+ thread = list(db.mails.find({'ThreadID': int(threadid)},
sort=[('Date', pymongo.ASCENDING)]))
tree = _build_thread(thread)
@@ -55,9 +55,12 @@ def get_thread_list(table, threadid):
def get_thread_name(table, threadid):
db = connection[table]
- thread = list(db.mails.find({'ThreadID': threadid},
- sort=[('Date', pymongo.ASCENDING)]))[0]
- return thread['Subject']
+ thread = list(db.mails.find({'ThreadID': int(threadid)},
+ sort=[('Date', pymongo.ASCENDING)]))
+ if thread:
+ return thread[0]['Subject']
+ else:
+ return ''
def get_emails_thread(table, start_email, thread):
db = connection[table]