[Nym3-commit] r513 - trunk/nymbaron/Server

jr at conuropsis.org jr at conuropsis.org
Sun Apr 9 18:42:37 CEST 2006


Author: jr
Date: 2006-04-09 18:42:36 +0200 (Sun, 09 Apr 2006)
New Revision: 513

Modified:
   trunk/nymbaron/Server/User.py
Log:
- Add a synbox time seek
- Correct a bug in midAfter
- Inits in sendOldContent


Modified: trunk/nymbaron/Server/User.py
===================================================================
--- trunk/nymbaron/Server/User.py	2006-04-08 13:24:02 UTC (rev 512)
+++ trunk/nymbaron/Server/User.py	2006-04-09 16:42:36 UTC (rev 513)
@@ -323,7 +323,31 @@
             return self.mbox[mid]
         except:
             raise ValueError()
-        
+
+    def synTimeSeek(self, t):
+        """Returns a couple (i, j) so that all syns older than t are before the
+        syn at position j in blob i. throw IndexError if there are no syn
+        younger than t"""
+        propyoungblob = lambda x: self.index[x[0][0]]['time'] > t
+        propyoungmid = lambda x: self.index[x]['time'] > t
+        try:
+            i = binsearch(self.syn, propyoungblob)
+        except IndexError:
+            #There may be mids at the end of the last blob
+            nmids = self.syn[-1][0]
+            j = binsearch(nmids, propyoungmid)
+            #throws index error if there are no syn youger than t
+            return (len(self.syn) -1, j)
+        #there might be young syns in the blob i-1
+        if i > 0:
+            pmids = self.syn[i-1][0]
+            try:
+                j = binsearch(pmids, propyoungmid)
+                return (i-1, j)
+            except IndexError:
+                #There are no relevant mids in pmids
+                return (i, 0)
+    
     def midAfter(self, mid, num = -1):
         """Retrieve mids of messages that came strictly after message `mid'
         the elements of the output are ordered by ascending
@@ -368,6 +392,8 @@
                         ret = pmids[j:]
                     else:
                         ret = pmids[j:j+num]
+                        if len(ret) >= num:
+                            return ret[:num]
                 except IndexError:
                     #There are no relevant mids in pmids
                     pass
@@ -813,7 +839,13 @@
         """Checks wheter there are synopses and/or emails that have been there
         for longer than their maximum latency and try to send them"""
         #cf 2.3 items 2
+        self.load_synbox()
+        self.load_mbox()
+        self.load_index()
         #TODO list of syns to send
+        #synList is the ordered list of blobs that contains messages to be sent
+        tlim = time.time() - self.data['SendSummaryAfter'] * 30 * 60
+        #TODO cf midAfter
         #TODO list of emails to send
         #TODO determine what can be sent
         #TODO send it



More information about the Nym3-commit mailing list