[Mailman-Users] Reverse chronological date order for archives

Mark Sapiro mark at msapiro.net
Thu Nov 19 01:43:44 EST 2015


On 11/18/15 7:03 PM, ListGnome ProtonMail wrote:
> Hi Mark,
> 
> I was referring to the date.html page - but it would also apply to all
> the other views - whereby the most recent post is always at the top
> rather than the bottom.
> 
> I found another post (from 2004) where the author modified the
> HyperDatabase.py file and says that managed to reverse the chronological
> date order.
> 
> https://www.mail-archive.com/mailman-users%40python.org/msg28944.html
> 
> I had a look at the HyperDatabase.py file in my version (2.1.20) and the
> code that he shows doesn't exist in my file.
...


The patch in that post is against Mailman 2.1.5. The reason you can't
find that code in any HyperDatabase.py is the patch is 'reversed' and
the lines that show as deleted were actually added. A proper context
diff for that patch is

$ diff -u HyperDatabase.py.old HyperDatabase.py
--- HyperDatabase.py.old	2015-11-18 22:15:25.000000000 -0800
+++ HyperDatabase.py	2015-11-18 22:20:43.000000000 -0800
@@ -291,9 +291,14 @@

     def first(self, archive, index):
         self.__openIndices(archive)
+        if index == 'date': dateIndex = 1
+        else: dateIndex = 0
         index = getattr(self, index + 'Index')
         try:
             key, msgid = index.first()
+            if dateIndex == 1:
+                index.sorted.reverse()
+                key, msgid = index.first()
             return msgid
         except KeyError:
             return None

And the patch refactored for style against 2.1.20 is

$ diff -u 2.1/Mailman/Archiver/HyperDatabase.py
21/Mailman/Archiver/HyperDatabase.py
--- 2.1/Mailman/Archiver/HyperDatabase.py	2013-05-31 14:44:32.000000000
-0700
+++ 21/Mailman/Archiver/HyperDatabase.py	2015-11-18 22:32:14.000000000 -0800
@@ -297,8 +297,14 @@

     def first(self, archive, index):
         self.__openIndices(archive)
+        if index == 'date':
+            dateIndex = 1
+        else:
+            dateIndex = 0
         index = getattr(self, index + 'Index')
         try:
+            if dateIndex == 1:
+                index.sorted.reverse()
             key, msgid = index.first()
             return msgid
         except KeyError:


I note three things.
1) I have not tested the patch. It looks like it might work, but no
guarantees.
2) The patch only affects the date index.
3) After installing the patch and restarting Mailman, the current period
date index for a list should be reordered with the next post to that
list, but older date index files will not be unless you rebuild the
archive with bin/arch --wipe. See the section "NOTE ON MBOX ANOMALIES:"
in the FAQ at <http://wiki.list.org/x/4030681> for caveats before doing
this.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan


More information about the Mailman-Users mailing list