Merge lp:~danci-emanuel/mailman/messages_support into lp:~danci-emanuel/mailman/dlist_runner
- messages_support
- Merge into dlist_runner
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Terri | Pending | ||
Robin J | Pending | ||
Review via email: mp+124798@code.launchpad.net |
Commit message
Description of the change
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.
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!
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
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.
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
1 | === modified file 'src/mailman/app/moderator.py' | |||
2 | --- src/mailman/app/moderator.py 2012-03-15 22:48:41 +0000 | |||
3 | +++ src/mailman/app/moderator.py 2012-09-17 21:12:24 +0000 | |||
4 | @@ -90,7 +90,7 @@ | |||
5 | 90 | msg['Message-ID'] = message_id = unicode(make_msgid()) | 90 | msg['Message-ID'] = message_id = unicode(make_msgid()) |
6 | 91 | assert isinstance(message_id, unicode), ( | 91 | assert isinstance(message_id, unicode), ( |
7 | 92 | 'Message-ID is not a unicode: %s' % message_id) | 92 | 'Message-ID is not a unicode: %s' % message_id) |
9 | 93 | getUtility(IMessageStore).add(msg) | 93 | getUtility(IMessageStore).add(msg, msgdata) |
10 | 94 | # Prepare the message metadata with some extra information needed only by | 94 | # Prepare the message metadata with some extra information needed only by |
11 | 95 | # the moderation interface. | 95 | # the moderation interface. |
12 | 96 | msgdata['_mod_message_id'] = message_id | 96 | msgdata['_mod_message_id'] = message_id |
13 | 97 | 97 | ||
14 | === modified file 'src/mailman/database/schema/postgres.sql' | |||
15 | --- src/mailman/database/schema/postgres.sql 2012-09-11 18:17:03 +0000 | |||
16 | +++ src/mailman/database/schema/postgres.sql 2012-09-17 21:12:24 +0000 | |||
17 | @@ -291,6 +291,7 @@ | |||
18 | 291 | message_id_hash BYTEA, | 291 | message_id_hash BYTEA, |
19 | 292 | path BYTEA, | 292 | path BYTEA, |
20 | 293 | message_id TEXT, | 293 | message_id TEXT, |
21 | 294 | thread_id_dlist INTEGER, | ||
22 | 294 | PRIMARY KEY (id) | 295 | PRIMARY KEY (id) |
23 | 295 | ); | 296 | ); |
24 | 296 | 297 | ||
25 | 297 | 298 | ||
26 | === modified file 'src/mailman/database/schema/sqlite.sql' | |||
27 | --- src/mailman/database/schema/sqlite.sql 2012-09-11 18:17:03 +0000 | |||
28 | +++ src/mailman/database/schema/sqlite.sql 2012-09-17 21:12:24 +0000 | |||
29 | @@ -239,6 +239,7 @@ | |||
30 | 239 | message_id_hash TEXT, | 239 | message_id_hash TEXT, |
31 | 240 | path TEXT, | 240 | path TEXT, |
32 | 241 | message_id TEXT, | 241 | message_id TEXT, |
33 | 242 | thread_id_dlist INTEGER, | ||
34 | 242 | PRIMARY KEY (id) | 243 | PRIMARY KEY (id) |
35 | 243 | ); | 244 | ); |
36 | 244 | 245 | ||
37 | 245 | 246 | ||
38 | === modified file 'src/mailman/interfaces/mailinglist.py' | |||
39 | --- src/mailman/interfaces/mailinglist.py 2012-09-11 18:17:03 +0000 | |||
40 | +++ src/mailman/interfaces/mailinglist.py 2012-09-17 21:12:24 +0000 | |||
41 | @@ -133,7 +133,7 @@ | |||
42 | 133 | available mailing lists.""") | 133 | available mailing lists.""") |
43 | 134 | 134 | ||
44 | 135 | dlists_enabled = Attribute( | 135 | dlists_enabled = Attribute( |
46 | 136 | """Is the Dynamic sublists feature enabled for this list?""") | 136 | """Allow people to (un)subscribe to individual conversations?""") |
47 | 137 | 137 | ||
48 | 138 | # Contact addresses | 138 | # Contact addresses |
49 | 139 | 139 | ||
50 | 140 | 140 | ||
51 | === modified file 'src/mailman/interfaces/messages.py' | |||
52 | --- src/mailman/interfaces/messages.py 2012-01-01 19:14:46 +0000 | |||
53 | +++ src/mailman/interfaces/messages.py 2012-09-17 21:12:24 +0000 | |||
54 | @@ -62,12 +62,13 @@ | |||
55 | 62 | http://archive.example.com/RXTJ357KFOTJP3NFJA6KMO65X7VQOHJI | 62 | http://archive.example.com/RXTJ357KFOTJP3NFJA6KMO65X7VQOHJI |
56 | 63 | """ | 63 | """ |
57 | 64 | 64 | ||
59 | 65 | def add(message): | 65 | def add(message, msgdata): |
60 | 66 | """Add the message to the store. | 66 | """Add the message to the store. |
61 | 67 | 67 | ||
62 | 68 | :param message: An email.message.Message instance containing at least | 68 | :param message: An email.message.Message instance containing at least |
63 | 69 | a unique Message-ID header. The message will be given an | 69 | a unique Message-ID header. The message will be given an |
64 | 70 | X-Message-ID-Hash header, overriding any existing such header. | 70 | X-Message-ID-Hash header, overriding any existing such header. |
65 | 71 | :param msgdata: The message metadata. | ||
66 | 71 | :returns: The calculated X-Message-ID-Hash header. | 72 | :returns: The calculated X-Message-ID-Hash header. |
67 | 72 | :raises ValueError: if the message is missing a Message-ID header. | 73 | :raises ValueError: if the message is missing a Message-ID header. |
68 | 73 | The storage service is also allowed to raise this exception if it | 74 | The storage service is also allowed to raise this exception if it |
69 | @@ -109,3 +110,6 @@ | |||
70 | 109 | message_id_hash = Attribute("""The unique SHA1 hash of the message.""") | 110 | message_id_hash = Attribute("""The unique SHA1 hash of the message.""") |
71 | 110 | 111 | ||
72 | 111 | path = Attribute("""The filesystem path to the message object.""") | 112 | path = Attribute("""The filesystem path to the message object.""") |
73 | 113 | |||
74 | 114 | thread_id_dlist = Attribute("""The id of the thread that the message | ||
75 | 115 | belongs to.""") | ||
76 | 112 | 116 | ||
77 | === modified file 'src/mailman/model/message.py' | |||
78 | --- src/mailman/model/message.py 2012-04-26 02:08:22 +0000 | |||
79 | +++ src/mailman/model/message.py 2012-09-17 21:12:24 +0000 | |||
80 | @@ -41,12 +41,15 @@ | |||
81 | 41 | message_id = Unicode() | 41 | message_id = Unicode() |
82 | 42 | message_id_hash = RawStr() | 42 | message_id_hash = RawStr() |
83 | 43 | path = RawStr() | 43 | path = RawStr() |
84 | 44 | thread_id_dlist = Int() | ||
85 | 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. |
86 | 45 | 46 | ||
87 | 46 | @dbconnection | 47 | @dbconnection |
89 | 47 | def __init__(self, store, message_id, message_id_hash, path): | 48 | def __init__(self, store, message_id, message_id_hash, path, |
90 | 49 | thread_id_dlist): | ||
91 | 48 | super(Message, self).__init__() | 50 | super(Message, self).__init__() |
92 | 49 | self.message_id = message_id | 51 | self.message_id = message_id |
93 | 50 | self.message_id_hash = message_id_hash | 52 | self.message_id_hash = message_id_hash |
94 | 51 | self.path = path | 53 | self.path = path |
95 | 54 | self.thread_id_dlist = thread_id_dlist | ||
96 | 52 | store.add(self) | 55 | store.add(self) |
97 | 53 | 56 | ||
98 | === modified file 'src/mailman/model/messagestore.py' | |||
99 | --- src/mailman/model/messagestore.py 2012-04-26 02:08:22 +0000 | |||
100 | +++ src/mailman/model/messagestore.py 2012-09-17 21:12:24 +0000 | |||
101 | @@ -51,9 +51,12 @@ | |||
102 | 51 | """See `IMessageStore`.""" | 51 | """See `IMessageStore`.""" |
103 | 52 | 52 | ||
104 | 53 | @dbconnection | 53 | @dbconnection |
106 | 54 | def add(self, store, message): | 54 | def add(self, store, message, msgdata): |
107 | 55 | return | ||
108 | 55 | # Ensure that the message has the requisite headers. | 56 | # Ensure that the message has the requisite headers. |
109 | 56 | message_ids = message.get_all('message-id', []) | 57 | message_ids = message.get_all('message-id', []) |
110 | 58 | for i in range(len(message_ids)): | ||
111 | 59 | print( message_ids[i] ) | ||
112 | 57 | if len(message_ids) <> 1: | 60 | if len(message_ids) <> 1: |
113 | 58 | raise ValueError('Exactly one Message-ID header required') | 61 | raise ValueError('Exactly one Message-ID header required') |
114 | 59 | # Calculate and insert the X-Message-ID-Hash. | 62 | # Calculate and insert the X-Message-ID-Hash. |
115 | @@ -76,13 +79,19 @@ | |||
116 | 76 | parts.append(split.pop(0) + split.pop(0)) | 79 | parts.append(split.pop(0) + split.pop(0)) |
117 | 77 | parts.append(hash32) | 80 | parts.append(hash32) |
118 | 78 | relpath = os.path.join(*parts) | 81 | relpath = os.path.join(*parts) |
119 | 82 | # extract the thread_id | ||
120 | 83 | try: | ||
121 | 84 | thread_id = msgdata['thread_id'] | ||
122 | 85 | except: | ||
123 | 86 | thread_id = -1 | ||
124 | 79 | # Store the message in the database. This relies on the database | 87 | # Store the message in the database. This relies on the database |
125 | 80 | # providing a unique serial number, but to get this information, we | 88 | # providing a unique serial number, but to get this information, we |
126 | 81 | # have to use a straight insert instead of relying on Elixir to create | 89 | # have to use a straight insert instead of relying on Elixir to create |
127 | 82 | # the object. | 90 | # the object. |
128 | 83 | row = Message(message_id=message_id, | 91 | row = Message(message_id=message_id, |
129 | 84 | message_id_hash=hash32, | 92 | message_id_hash=hash32, |
131 | 85 | path=relpath) | 93 | path=relpath, |
132 | 94 | thread_id_dlist=thread_id) | ||
133 | 86 | # Now calculate the full file system path. | 95 | # Now calculate the full file system path. |
134 | 87 | path = os.path.join(config.MESSAGES_DIR, relpath) | 96 | path = os.path.join(config.MESSAGES_DIR, relpath) |
135 | 88 | # Write the file to the path, but catch the appropriate exception in | 97 | # Write the file to the path, but catch the appropriate exception in |
136 | 89 | 98 | ||
137 | === modified file 'src/mailman/rules/max_size.py' | |||
138 | --- src/mailman/rules/max_size.py 2012-09-11 17:20:51 +0000 | |||
139 | +++ src/mailman/rules/max_size.py 2012-09-17 21:12:24 +0000 | |||
140 | @@ -3,6 +3,7 @@ | |||
141 | 3 | # This file is part of GNU Mailman. | 3 | # This file is part of GNU Mailman. |
142 | 4 | # | 4 | # |
143 | 5 | # GNU Mailman is free software: you can redistribute it and/or modify it under | 5 | # GNU Mailman is free software: you can redistribute it and/or modify it under |
144 | 6 | # the terms of the GNU General Public License as published by the Free | ||
145 | 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) |
146 | 7 | # any later version. | 8 | # any later version. |
147 | 8 | # | 9 | # |
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.