Merge lp:~danci-emanuel/mailman/messages_support into lp:~danci-emanuel/mailman/dlist_runner

Proposed by Emanuel Danci
Status: Needs review
Proposed branch: lp:~danci-emanuel/mailman/messages_support
Merge into: lp:~danci-emanuel/mailman/dlist_runner
Diff against target: 147 lines (+25/-6)
8 files modified
src/mailman/app/moderator.py (+1/-1)
src/mailman/database/schema/postgres.sql (+1/-0)
src/mailman/database/schema/sqlite.sql (+1/-0)
src/mailman/interfaces/mailinglist.py (+1/-1)
src/mailman/interfaces/messages.py (+5/-1)
src/mailman/model/message.py (+4/-1)
src/mailman/model/messagestore.py (+11/-2)
src/mailman/rules/max_size.py (+1/-0)
To merge this branch: bzr merge lp:~danci-emanuel/mailman/messages_support
Reviewer Review Type Date Requested Status
Terri Pending
Robin J Pending
Review via email: mp+124798@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Emanuel Danci (danci-emanuel) wrote :

Just some small comments:

1. This is only the part that will be used by the handlers when creating the new messags. (the equivalent of the Message class from DlistUtils)

2. I did not push the code for the other parts of the DlistUtils (the ones related to the Thread and Override classes) because I still have to finish some parts of them and I also took you advice, pushing smaller pieces of code, so that they will be easier to review.

3. I also changed the attribute from mailinglist.py, the one that you told me to, and added the missing line to max_size.py.

4. I tried to add Terri as I reviewer to, but I cannot seem to find her on launchpad.

Revision history for this message
Robin J (robin-jeffries) wrote :

> Just some small comments:
>
> 1. This is only the part that will be used by the handlers when creating the
> new messags. (the equivalent of the Message class from DlistUtils)

OK, I don't think I understand why existing mailman doesn't include the msgdata, but you need to. Can you explain it to me? (It's probably because I don't know the mm3 code, but it will help us both if you can explain it.) What is in the metadata?

>
> 2. I did not push the code for the other parts of the DlistUtils (the ones
> related to the Thread and Override classes) because I still have to finish
> some parts of them and I also took you advice, pushing smaller pieces of code,
> so that they will be easier to review.

Good.

>
> 3. I also changed the attribute from mailinglist.py, the one that you told me
> to, and added the missing line to max_size.py.

You mean the help text associated with that attribute?

>
> 4. I tried to add Terri as I reviewer to, but I cannot seem to find her on
> launchpad.

I can't figure out how to add another reviewer from this view, but Terri is terriko on launchpad.

Revision history for this message
Emanuel Danci (danci-emanuel) wrote :

> > Just some small comments:
> >
> > 1. This is only the part that will be used by the handlers when creating the
> > new messags. (the equivalent of the Message class from DlistUtils)
>
> OK, I don't think I understand why existing mailman doesn't include the
> msgdata, but you need to. Can you explain it to me? (It's probably because I
> don't know the mm3 code, but it will help us both if you can explain it.)
> What is in the metadata?
>

Right not, mm3 only stores the following information for a certain message: the message_id_hash, its path and the message_id, which are all found in the msg param. I added the msgdata because it contains the 'thread_id' field, which will be added by the one of the two handlers (either FirstDlist or SecondDlist, as Sneha Priscilla called them), when the message gets there.

> >
> > 2. I did not push the code for the other parts of the DlistUtils (the ones
> > related to the Thread and Override classes) because I still have to finish
> > some parts of them and I also took you advice, pushing smaller pieces of
> code,
> > so that they will be easier to review.
>
> Good.
>
> >
> > 3. I also changed the attribute from mailinglist.py, the one that you told
> me
> > to, and added the missing line to max_size.py.
>
> You mean the help text associated with that attribute?

Yes, the text.

> >
> > 4. I tried to add Terri as I reviewer to, but I cannot seem to find her on
> > launchpad.
>
> I can't figure out how to add another reviewer from this view, but Terri is
> terriko on launchpad.

Thank you for Terri`s id! I added her to the reviewers list, too!

Revision history for this message
Robin J (robin-jeffries) wrote :

> > > Just some small comments:
> > >
> > > 1. This is only the part that will be used by the handlers when creating
> the
> > > new messags. (the equivalent of the Message class from DlistUtils)
> >
> > OK, I don't think I understand why existing mailman doesn't include the
> > msgdata, but you need to. Can you explain it to me? (It's probably because
> I
> > don't know the mm3 code, but it will help us both if you can explain it.)
> > What is in the metadata?
> >
>
> Right not, mm3 only stores the following information for a certain message:
> the message_id_hash, its path and the message_id, which are all found in the
> msg param. I added the msgdata because it contains the 'thread_id' field,
> which will be added by the one of the two handlers (either FirstDlist or
> SecondDlist, as Sneha Priscilla called them), when the message gets there.
>

So, msg is an object, so why not just make the thread_id an attribute of the object? (I don't want us to get to far away from what mailman is doing, and that seems to be what mailman is doing with the other info about the message)

I'm refering to
  moderator.py
  messages.py

Revision history for this message
Emanuel Danci (danci-emanuel) wrote :

> > > > Just some small comments:
> > > >
> > > > 1. This is only the part that will be used by the handlers when creating
> > the
> > > > new messags. (the equivalent of the Message class from DlistUtils)
> > >
> > > OK, I don't think I understand why existing mailman doesn't include the
> > > msgdata, but you need to. Can you explain it to me? (It's probably
> because
> > I
> > > don't know the mm3 code, but it will help us both if you can explain it.)
> > > What is in the metadata?
> > >
> >
> > Right not, mm3 only stores the following information for a certain message:
> > the message_id_hash, its path and the message_id, which are all found in the
> > msg param. I added the msgdata because it contains the 'thread_id' field,
> > which will be added by the one of the two handlers (either FirstDlist or
> > SecondDlist, as Sneha Priscilla called them), when the message gets there.
> >
>
> So, msg is an object, so why not just make the thread_id an attribute of the
> object? (I don't want us to get to far away from what mailman is doing, and
> that seems to be what mailman is doing with the other info about the message)
>
> I'm refering to
> moderator.py
> messages.py

Yes, theoretically that can be done. So than I should go with changing the initial dlist model and add the 'thread_id' to msg instead of adding it to the msgdata? This means that I will only have to keep in mind to search the thread_id in the msg object instead of the msgdata one, when doing the rest of the actions from DlistUtils.

Revision history for this message
Robin J (robin-jeffries) wrote :

> > So, msg is an object, so why not just make the thread_id an attribute of the
> > object? (I don't want us to get to far away from what mailman is doing, and
> > that seems to be what mailman is doing with the other info about the
> message)
> >
> > I'm refering to
> > moderator.py
> > messages.py
>
> Yes, theoretically that can be done. So than I should go with changing the
> initial dlist model and add the 'thread_id' to msg instead of adding it to the
> msgdata? This means that I will only have to keep in mind to search the
> thread_id in the msg object instead of the msgdata one, when doing the rest of
> the actions from DlistUtils.

Yes, this makes it easier for you, and doesn't confuse a future reader of the code about why thread_id is different from other data related to the message. (The old dlists were a private addon, so they wanted to keep as much separate from existing mm objects as possible, but this work is going into core mailman 3, so it's more important that it be parallel to other parts of that code)

Unmerged revisions

7165. By Emanuel Danci

Added the missing part from the messages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/mailman/app/moderator.py'
--- src/mailman/app/moderator.py 2012-03-15 22:48:41 +0000
+++ src/mailman/app/moderator.py 2012-09-17 21:12:24 +0000
@@ -90,7 +90,7 @@
90 msg['Message-ID'] = message_id = unicode(make_msgid())90 msg['Message-ID'] = message_id = unicode(make_msgid())
91 assert isinstance(message_id, unicode), (91 assert isinstance(message_id, unicode), (
92 'Message-ID is not a unicode: %s' % message_id)92 'Message-ID is not a unicode: %s' % message_id)
93 getUtility(IMessageStore).add(msg)93 getUtility(IMessageStore).add(msg, msgdata)
94 # Prepare the message metadata with some extra information needed only by94 # Prepare the message metadata with some extra information needed only by
95 # the moderation interface.95 # the moderation interface.
96 msgdata['_mod_message_id'] = message_id96 msgdata['_mod_message_id'] = message_id
9797
=== modified file 'src/mailman/database/schema/postgres.sql'
--- src/mailman/database/schema/postgres.sql 2012-09-11 18:17:03 +0000
+++ src/mailman/database/schema/postgres.sql 2012-09-17 21:12:24 +0000
@@ -291,6 +291,7 @@
291 message_id_hash BYTEA,291 message_id_hash BYTEA,
292 path BYTEA,292 path BYTEA,
293 message_id TEXT,293 message_id TEXT,
294 thread_id_dlist INTEGER,
294 PRIMARY KEY (id)295 PRIMARY KEY (id)
295 );296 );
296297
297298
=== modified file 'src/mailman/database/schema/sqlite.sql'
--- src/mailman/database/schema/sqlite.sql 2012-09-11 18:17:03 +0000
+++ src/mailman/database/schema/sqlite.sql 2012-09-17 21:12:24 +0000
@@ -239,6 +239,7 @@
239 message_id_hash TEXT,239 message_id_hash TEXT,
240 path TEXT,240 path TEXT,
241 message_id TEXT,241 message_id TEXT,
242 thread_id_dlist INTEGER,
242 PRIMARY KEY (id)243 PRIMARY KEY (id)
243 );244 );
244245
245246
=== modified file 'src/mailman/interfaces/mailinglist.py'
--- src/mailman/interfaces/mailinglist.py 2012-09-11 18:17:03 +0000
+++ src/mailman/interfaces/mailinglist.py 2012-09-17 21:12:24 +0000
@@ -133,7 +133,7 @@
133 available mailing lists.""")133 available mailing lists.""")
134134
135 dlists_enabled = Attribute(135 dlists_enabled = Attribute(
136 """Is the Dynamic sublists feature enabled for this list?""")136 """Allow people to (un)subscribe to individual conversations?""")
137 137
138 # Contact addresses138 # Contact addresses
139139
140140
=== modified file 'src/mailman/interfaces/messages.py'
--- src/mailman/interfaces/messages.py 2012-01-01 19:14:46 +0000
+++ src/mailman/interfaces/messages.py 2012-09-17 21:12:24 +0000
@@ -62,12 +62,13 @@
62 http://archive.example.com/RXTJ357KFOTJP3NFJA6KMO65X7VQOHJI62 http://archive.example.com/RXTJ357KFOTJP3NFJA6KMO65X7VQOHJI
63 """63 """
6464
65 def add(message):65 def add(message, msgdata):
66 """Add the message to the store.66 """Add the message to the store.
6767
68 :param message: An email.message.Message instance containing at least68 :param message: An email.message.Message instance containing at least
69 a unique Message-ID header. The message will be given an69 a unique Message-ID header. The message will be given an
70 X-Message-ID-Hash header, overriding any existing such header.70 X-Message-ID-Hash header, overriding any existing such header.
71 :param msgdata: The message metadata.
71 :returns: The calculated X-Message-ID-Hash header.72 :returns: The calculated X-Message-ID-Hash header.
72 :raises ValueError: if the message is missing a Message-ID header.73 :raises ValueError: if the message is missing a Message-ID header.
73 The storage service is also allowed to raise this exception if it74 The storage service is also allowed to raise this exception if it
@@ -109,3 +110,6 @@
109 message_id_hash = Attribute("""The unique SHA1 hash of the message.""")110 message_id_hash = Attribute("""The unique SHA1 hash of the message.""")
110111
111 path = Attribute("""The filesystem path to the message object.""")112 path = Attribute("""The filesystem path to the message object.""")
113
114 thread_id_dlist = Attribute("""The id of the thread that the message
115 belongs to.""")
112116
=== modified file 'src/mailman/model/message.py'
--- src/mailman/model/message.py 2012-04-26 02:08:22 +0000
+++ src/mailman/model/message.py 2012-09-17 21:12:24 +0000
@@ -41,12 +41,15 @@
41 message_id = Unicode()41 message_id = Unicode()
42 message_id_hash = RawStr()42 message_id_hash = RawStr()
43 path = RawStr()43 path = RawStr()
44 thread_id_dlist = Int()
44 # This is a Messge-ID field representation, not a database row id.45 # This is a Messge-ID field representation, not a database row id.
4546
46 @dbconnection47 @dbconnection
47 def __init__(self, store, message_id, message_id_hash, path):48 def __init__(self, store, message_id, message_id_hash, path,
49 thread_id_dlist):
48 super(Message, self).__init__()50 super(Message, self).__init__()
49 self.message_id = message_id51 self.message_id = message_id
50 self.message_id_hash = message_id_hash52 self.message_id_hash = message_id_hash
51 self.path = path53 self.path = path
54 self.thread_id_dlist = thread_id_dlist
52 store.add(self)55 store.add(self)
5356
=== modified file 'src/mailman/model/messagestore.py'
--- src/mailman/model/messagestore.py 2012-04-26 02:08:22 +0000
+++ src/mailman/model/messagestore.py 2012-09-17 21:12:24 +0000
@@ -51,9 +51,12 @@
51 """See `IMessageStore`."""51 """See `IMessageStore`."""
5252
53 @dbconnection53 @dbconnection
54 def add(self, store, message):54 def add(self, store, message, msgdata):
55 return
55 # Ensure that the message has the requisite headers.56 # Ensure that the message has the requisite headers.
56 message_ids = message.get_all('message-id', [])57 message_ids = message.get_all('message-id', [])
58 for i in range(len(message_ids)):
59 print( message_ids[i] )
57 if len(message_ids) <> 1:60 if len(message_ids) <> 1:
58 raise ValueError('Exactly one Message-ID header required')61 raise ValueError('Exactly one Message-ID header required')
59 # Calculate and insert the X-Message-ID-Hash.62 # Calculate and insert the X-Message-ID-Hash.
@@ -76,13 +79,19 @@
76 parts.append(split.pop(0) + split.pop(0))79 parts.append(split.pop(0) + split.pop(0))
77 parts.append(hash32)80 parts.append(hash32)
78 relpath = os.path.join(*parts)81 relpath = os.path.join(*parts)
82 # extract the thread_id
83 try:
84 thread_id = msgdata['thread_id']
85 except:
86 thread_id = -1
79 # Store the message in the database. This relies on the database87 # Store the message in the database. This relies on the database
80 # providing a unique serial number, but to get this information, we88 # providing a unique serial number, but to get this information, we
81 # have to use a straight insert instead of relying on Elixir to create89 # have to use a straight insert instead of relying on Elixir to create
82 # the object.90 # the object.
83 row = Message(message_id=message_id,91 row = Message(message_id=message_id,
84 message_id_hash=hash32,92 message_id_hash=hash32,
85 path=relpath)93 path=relpath,
94 thread_id_dlist=thread_id)
86 # Now calculate the full file system path.95 # Now calculate the full file system path.
87 path = os.path.join(config.MESSAGES_DIR, relpath)96 path = os.path.join(config.MESSAGES_DIR, relpath)
88 # Write the file to the path, but catch the appropriate exception in97 # Write the file to the path, but catch the appropriate exception in
8998
=== modified file 'src/mailman/rules/max_size.py'
--- src/mailman/rules/max_size.py 2012-09-11 17:20:51 +0000
+++ src/mailman/rules/max_size.py 2012-09-17 21:12:24 +0000
@@ -3,6 +3,7 @@
3# This file is part of GNU Mailman.3# This file is part of GNU Mailman.
4#4#
5# GNU Mailman is free software: you can redistribute it and/or modify it under5# GNU Mailman is free software: you can redistribute it and/or modify it under
6# the terms of the GNU General Public License as published by the Free
6# Software Foundation, either version 3 of the License, or (at your option)7# Software Foundation, either version 3 of the License, or (at your option)
7# any later version.8# any later version.
8#9#

Subscribers

People subscribed via source and target branches

to all changes: