Merge lp:~systers-soc/systers/stable into lp:~systers-dev/systers/development

Proposed by kanika vats
Status: Merged
Merged at revision: 82
Proposed branch: lp:~systers-soc/systers/stable
Merge into: lp:~systers-dev/systers/development
Diff against target: 460 lines (+90/-76)
3 files modified
Mailman/DlistUtils.py (+88/-69)
Mailman/mm_cfg.py (+1/-1)
bin/rmlist (+1/-6)
To merge this branch: bzr merge lp:~systers-soc/systers/stable
Reviewer Review Type Date Requested Status
Kari Tornow (community) Approve
Robin J Approve
Review via email: mp+26266@code.launchpad.net

This proposal supersedes a proposal from 2010-05-26.

To post a comment you must log in.
Revision history for this message
Robin J (robin-jeffries) wrote : Posted in a previous version of this proposal
Download full text (19.3 KiB)

I'm learning how to do this. I will put comments below in the diff; let me
know if that is readable.
On thing I would like you to do is limit the line length, at least for new
lines you add, to 80 chars. You should be able to tell from the diff format
which lines have wrapped (in your changes). If you need help in figuring
out how best to do continuation lines, let me know (in my experience, you
sometimes have to wrap expressions in parens to make it work well -- at
least if you are using emacs and letting it do the formatting).

I have a few questions, that are as much for me to learn the code as
anything. There are 5 comments below, if I counted right. One I think is a
bug and the rest are style comments or questions. I will review your next
changes as soon as I get them.

review needsfixing

On Wed, May 26, 2010 at 11:45 AM, kanika vats <email address hidden>wrote:

> kanika vats has proposed merging lp:~systers-soc/systers/stable into
> lp:~systers-dev/systers/development.
>
> Requested reviews:
> Kari Tornow (kari-tornow)
> Robin J (robin-jeffries)
>
> --
> https://code.launchpad.net/~systers-soc/systers/stable/+merge/26090<https://code.launchpad.net/%7Esysters-soc/systers/stable/+merge/26090>
> You are requested to review the proposed merge of
> lp:~systers-soc/systers/stable into lp:~systers-dev/systers/development.
>
> === modified file 'Mailman/DlistUtils.py'
> --- Mailman/DlistUtils.py 2010-01-31 20:29:48 +0000
> +++ Mailman/DlistUtils.py 2010-05-26 18:45:43 +0000
> @@ -76,11 +76,11 @@
> if addr == None:
> return None
>
> - command = "result =
> self.store.find(Subscriber,Subscriber.mailman_key ==
> unicode(addr.lower(),'utf-8'))\na = [(subscriber.subscriber_id) for
> subscriber in result]\n"
> + command = "result =
> self.store.find(Subscriber,Subscriber.mailman_key.lower() ==
> unicode(addr.lower(),'utf-8'))\na = [(subscriber.subscriber_id) for
> subscriber in result]\n"
> if DEBUG_MODE:
> syslog('info', "DlistUtils:(getSubscriber_id_raw)executing
> query:\n%s", command)
> #storm recognizes unicode only
> - result = self.store.find(Subscriber,Subscriber.mailman_key ==
> unicode(addr.lower(),"utf-8"))
> + result = self.store.find(Subscriber,Subscriber.mailman_key.lower()
> == unicode(addr,"utf-8"))
> a = [(subscriber.subscriber_id) for subscriber in result]
> if DEBUG_MODE:
> syslog('info', 'value of a is: %s\n', a)
> @@ -136,10 +136,10 @@
> @decfunc
> def setDisable(self, member, flag):
> """Disable/enable delivery based on mm_cfg.DisableDelivery"""
> - command = "result =
> self.store.find(Subscriber,Subscriber.mailman_key ==
> unicode(member,'utf-8'))\noldval = [(subscriber.suppress) for subscriber in
> result]\n"
> + command = "result =
> self.store.find(Subscriber,Subscriber.mailman_key.lower() ==
> unicode(member,'utf-8'))\noldval = [(subscriber.suppress) for subscriber in
> result]\n"
> if DEBUG_MODE:
> syslog('info', 'DlistUtils(setDisable):Executing query:\n%s\n
> Member whoes suppress value is to be found \n %s', command,member)
>

can you put a spa...

Revision history for this message
kanika vats (kanika-krikan) wrote : Posted in a previous version of this proposal
Download full text (4.1 KiB)

> can you put a space in there
> command, member
> (a review is as much about style as substance)
> whoes => whose

Done

>
> Why is the commit not the last database command in the function? Actually,
> the other functions make changes, but they don't have a commit. What's the
> role of the commit?

Hmm..(I had previously explained the use of decorator function which is to wrap both the starting and ending of every function that is decorated with some common starting lines and ending lines)If you closely see decorator function at the top of DlistUtils you will see after

'result = f(self, *args)'->This executes all the commands defined in the function that calls the decorator function

you have

'self.store.commit()' ->Thus,this line is always executed after all the commands in the decorated function
                             are executed.

Thus the other functions make changes but they dont define commit explicitly because the decorator function automatically calls 'self.store.commit() after the complete execution of that function(every function that has a "@decfunc" mentioned just before the start of function defination is decorated)

Now what is the role of commit??
->Whenever you call store functions in Storm to make changes in the database for eg to change the value of a particular attribute or to add new tuple or delete one etc then Storm calculates the changes but does not reflects them in the database until and unless you do a commit.

Now why the above function related to your question had a commit mentioned in it although it was decorated and decorator function would have committed anyway?
->The answer can be easily understood if we closely examine the store functions being used.
The first command is:

1)self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(oldaddr,"utf-8")).set(mailman_key = unicode(newaddr,"utf-8"))

This is setting the mailman_key to newaddr but like I said that this change wont get reflected to database without a commit.

Now the socond command executed after this is:

2)self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(newaddr.lower(),"utf-8")).set(deleted = False)

Its finding the database of the tuples which have mailman_key == newaddr and setting deleted to False.If I had not given a commit before, then this query would not have given correct results as the previous queries action would not have been reflected in the database.

I hope this explains everything regarding why the commit had to be explicitly used in the above function.

>
> So Email is a list, right? Why is it going to match the key (which I assume
> is a string)? And what if there are two people with that key? I realize
> that is an error condition, but what's going to happen?
>

Absolutely I added the above lines of code to make sure that If a person who was previously a member of the list with the email address in lowercase, now subscribes back again but this time preferring uppercase for the email name then the database does not gets corrupted and changes the subscriber.mailman_key to the newaddr(uppercase one) preferred.

I have added Email = Email[0] to remove the fault.

>
> in ...

Read more...

Revision history for this message
kanika vats (kanika-krikan) wrote : Posted in a previous version of this proposal

Also I have very less knowledge on how to do a merge and code review done.After committing the change will I have to resubmit the proposal or the present merge proposal will take into account new changes as well?

Revision history for this message
Jennifer Redman (jenred) wrote : Posted in a previous version of this proposal
Download full text (4.7 KiB)

Do not commit to stable commit to dev.

Jen

On May 27, 2010, at 10:42, kanika vats <email address hidden> wrote:

>
>> can you put a space in there
>> command, member
>> (a review is as much about style as substance)
>> whoes => whose
>
> Done
>
>>
>> Why is the commit not the last database command in the function?
>> Actually,
>> the other functions make changes, but they don't have a commit.
>> What's the
>> role of the commit?
>
> Hmm..(I had previously explained the use of decorator function which
> is to wrap both the starting and ending of every function that is
> decorated with some common starting lines and ending lines)If you
> closely see decorator function at the top of DlistUtils you will see
> after
>
> 'result = f(self, *args)'->This executes all the commands defined in
> the function that calls the decorator function
>
> you have
>
> 'self.store.commit()' ->Thus,this line is always executed after
> all the commands in the decorated function
> are executed.
>
> Thus the other functions make changes but they dont define commit
> explicitly because the decorator function automatically calls
> 'self.store.commit() after the complete execution of that function
> (every function that has a "@decfunc" mentioned just before the
> start of function defination is decorated)
>
> Now what is the role of commit??
> ->Whenever you call store functions in Storm to make changes in the
> database for eg to change the value of a particular attribute or to
> add new tuple or delete one etc then Storm calculates the changes
> but does not reflects them in the database until and unless you do a
> commit.
>
> Now why the above function related to your question had a commit
> mentioned in it although it was decorated and decorator function
> would have committed anyway?
> ->The answer can be easily understood if we closely examine the
> store functions being used.
> The first command is:
>
> 1)self.store.find(Subscriber,Subscriber.mailman_key.lower() ==
> unicode(oldaddr,"utf-8")).set(mailman_key = unicode(newaddr,"utf-8"))
>
> This is setting the mailman_key to newaddr but like I said that this
> change wont get reflected to database without a commit.
>
> Now the socond command executed after this is:
>
> 2)self.store.find(Subscriber,Subscriber.mailman_key.lower() ==
> unicode(newaddr.lower(),"utf-8")).set(deleted = False)
>
> Its finding the database of the tuples which have mailman_key ==
> newaddr and setting deleted to False.If I had not given a commit
> before, then this query would not have given correct results as the
> previous queries action would not have been reflected in the database.
>
> I hope this explains everything regarding why the commit had to be
> explicitly used in the above function.
>
>
>>
>> So Email is a list, right? Why is it going to match the key (which
>> I assume
>> is a string)? And what if there are two people with that key? I
>> realize
>> that is an error condition, but what's going to happen?
>>
>
> Absolutely I added the above lines of code to make sure that If a
> person who was previously a member of the list ...

Read more...

Revision history for this message
kanika vats (kanika-krikan) wrote : Posted in a previous version of this proposal
Download full text (5.4 KiB)

Hi Jen,
I can not commit to the development branch as I see that I do not have
permissions.It says that only members of Systers can do it.If you give me
permissions that I will make a commit to it.
Thanks

On Thu, May 27, 2010 at 11:15 PM, Jennifer Redman <email address hidden> wrote:

> Do not commit to stable commit to dev.
>
> Jen
>
>
>
> On May 27, 2010, at 10:42, kanika vats <email address hidden> wrote:
>
> >
> >> can you put a space in there
> >> command, member
> >> (a review is as much about style as substance)
> >> whoes => whose
> >
> > Done
> >
> >>
> >> Why is the commit not the last database command in the function?
> >> Actually,
> >> the other functions make changes, but they don't have a commit.
> >> What's the
> >> role of the commit?
> >
> > Hmm..(I had previously explained the use of decorator function which
> > is to wrap both the starting and ending of every function that is
> > decorated with some common starting lines and ending lines)If you
> > closely see decorator function at the top of DlistUtils you will see
> > after
> >
> > 'result = f(self, *args)'->This executes all the commands defined in
> > the function that calls the decorator function
> >
> > you have
> >
> > 'self.store.commit()' ->Thus,this line is always executed after
> > all the commands in the decorated function
> > are executed.
> >
> > Thus the other functions make changes but they dont define commit
> > explicitly because the decorator function automatically calls
> > 'self.store.commit() after the complete execution of that function
> > (every function that has a "@decfunc" mentioned just before the
> > start of function defination is decorated)
> >
> > Now what is the role of commit??
> > ->Whenever you call store functions in Storm to make changes in the
> > database for eg to change the value of a particular attribute or to
> > add new tuple or delete one etc then Storm calculates the changes
> > but does not reflects them in the database until and unless you do a
> > commit.
> >
> > Now why the above function related to your question had a commit
> > mentioned in it although it was decorated and decorator function
> > would have committed anyway?
> > ->The answer can be easily understood if we closely examine the
> > store functions being used.
> > The first command is:
> >
> > 1)self.store.find(Subscriber,Subscriber.mailman_key.lower() ==
> > unicode(oldaddr,"utf-8")).set(mailman_key = unicode(newaddr,"utf-8"))
> >
> > This is setting the mailman_key to newaddr but like I said that this
> > change wont get reflected to database without a commit.
> >
> > Now the socond command executed after this is:
> >
> > 2)self.store.find(Subscriber,Subscriber.mailman_key.lower() ==
> > unicode(newaddr.lower(),"utf-8")).set(deleted = False)
> >
> > Its finding the database of the tuples which have mailman_key ==
> > newaddr and setting deleted to False.If I had not given a commit
> > before, then this query would not have given correct results as the
> > previous queries action would not have been reflected in the database.
> >
> > I hope this explains everything regarding why the commit had to be
> > explicitly used in...

Read more...

Revision history for this message
Robin J (robin-jeffries) wrote : Posted in a previous version of this proposal

review needsfixing

Trying to figure out how to make this work correctly.

Robin

On Wed, May 26, 2010 at 10:00 PM, Robin J <email address hidden> wrote:

> I'm learning how to do this. I will put comments below in the diff; let me
> know if that is readable.
>
> > kanika vats has proposed merging lp:~systers-soc/systers/stable into
> > lp:~systers-dev/systers/development.
> >
> > Requested reviews:
> > Kari Tornow (kari-tornow)
> > Robin J (robin-jeffries)
> >
> > --
> > https://code.launchpad.net/~systers-soc/systers/stable/+merge/26090<https://code.launchpad.net/%7Esysters-soc/systers/stable/+merge/26090>
> <https://code.launchpad.net/%7Esysters-soc/systers/stable/+merge/26090>
> > You are requested to review the proposed merge of
> > lp:~systers-soc/systers/stable into lp:~systers-dev/systers/development.
> >
> > === modified file 'Mailman/DlistUtils.py'
> > --- Mailman/DlistUtils.py 2010-01-31 20:29:48 +0000
> > +++ Mailman/DlistUtils.py 2010-05-26 18:45:43 +0000
> > @@ -76,11 +76,11 @@
> > if addr == None:
> > return None
>

Revision history for this message
Robin J (robin-jeffries) wrote : Posted in a previous version of this proposal

Yeah, apparently it doesn't take them into account. I see a link in the
upper right that says "Resubmit proposal". Why don't you see what that
does? (I still haven't figured out why it won't make sense of my review)

Robin

On Thu, May 27, 2010 at 10:45 AM, kanika vats <email address hidden>wrote:

> Also I have very less knowledge on how to do a merge and code review
> done.After committing the change will I have to resubmit the proposal or the
> present merge proposal will take into account new changes as well?
> --
> https://code.launchpad.net/~systers-soc/systers/stable/+merge/26090
> You are requested to review the proposed merge of
> lp:~systers-soc/systers/stable into lp:~systers-dev/systers/development.
>

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

OK, I did this on the web, not via email. Let's see if it takes.

I'm happy with all the changes. We are ready to go, but
   - Kari, can you approve this ASAP. I want you to get the experience of seeing how a code review goes.
   - Jen, what should Kanika Vats do next? does she need to delete this proposal and remerge to a different branch? Is there a way to reparent this?

review: Approve
Revision history for this message
Kari Tornow (kari-tornow) wrote :

I am glad to see Robin give comments on the aesthetics of the code. I feel that is important. I hope to review in depth on the next go round.

Revision history for this message
Kari Tornow (kari-tornow) wrote :

Comments added in prior notes.

review: Approve
Revision history for this message
Kari Tornow (kari-tornow) wrote :

Approved via web. Seemed to work.

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Robin J
Sent: Thursday, May 27, 2010 11:09 PM
To: <email address hidden>
Subject: Re: [Merge] lp:~systers-soc/systers/stable into lp:~systers-dev/systers/development

Review: Approve
OK, I did this on the web, not via email. Let's see if it takes.

I'm happy with all the changes. We are ready to go, but
   - Kari, can you approve this ASAP. I want you to get the experience of seeing how a code review goes.
   - Jen, what should Kanika Vats do next? does she need to delete this proposal and remerge to a different branch? Is there a way to reparent this?
--
https://code.launchpad.net/~systers-soc/systers/stable/+merge/26266
You are requested to review the proposed merge of lp:~systers-soc/systers/stable into lp:~systers-dev/systers/development.

This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

Revision history for this message
Kari Tornow (kari-tornow) wrote :

Approve without review.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Mailman/DlistUtils.py'
2--- Mailman/DlistUtils.py 2010-01-31 20:29:48 +0000
3+++ Mailman/DlistUtils.py 2010-05-28 04:55:39 +0000
4@@ -40,17 +40,17 @@
5 if self == classObject:
6 if self.store == None:#for the case when same object is used for calling more than one functions
7 self.store = Store(self.database)
8- result = f(self,*args)
9+ result = f(self, *args)
10 self.store.commit()
11 self.store.close()
12 self.store = None
13 else:#To handle the nesting issue
14- result = f(self,*args)
15+ result = f(self, *args)
16 self.store.commit()
17 else:#for the case whenever a new object calls its decorated member function
18 classObject = self
19 self.store = Store(self.database)
20- result = f(self,*args)
21+ result = f(self, *args)
22 self.store.commit()
23 self.store.close()
24 self.store = None
25@@ -60,14 +60,14 @@
26 #Define all the classes corresponding to the tables in the database
27 class Subscriber(object):
28 __storm_table__ = "subscriber"
29- subscriber_id = Int(primary = True,default = AutoReload)
30+ subscriber_id = Int(primary = True, default = AutoReload)
31 mailman_key = Unicode()
32 preference = Int(default = 1)
33 format = Int(default = 3)
34 deleted = Bool(default = False)
35 suppress = Int(default = 0)
36
37- def __init__(self,mlist):
38+ def __init__(self, mlist):
39 self.mlist = mlist
40 self.database = getConn(mlist)
41
42@@ -76,11 +76,11 @@
43 if addr == None:
44 return None
45
46- command = "result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(addr.lower(),'utf-8'))\na = [(subscriber.subscriber_id) for subscriber in result]\n"
47+ command = "result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(addr.lower(),'utf-8'))\na = [(subscriber.subscriber_id) for subscriber in result]\n"
48 if DEBUG_MODE:
49 syslog('info', "DlistUtils:(getSubscriber_id_raw)executing query:\n%s", command)
50 #storm recognizes unicode only
51- result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(addr.lower(),"utf-8"))
52+ result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(addr,"utf-8"))
53 a = [(subscriber.subscriber_id) for subscriber in result]
54 if DEBUG_MODE:
55 syslog('info', 'value of a is: %s\n', a)
56@@ -136,70 +136,70 @@
57 @decfunc
58 def setDisable(self, member, flag):
59 """Disable/enable delivery based on mm_cfg.DisableDelivery"""
60- command = "result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,'utf-8'))\noldval = [(subscriber.suppress) for subscriber in result]\n"
61+ command = "result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,'utf-8'))\noldval = [(subscriber.suppress) for subscriber in result]\n"
62 if DEBUG_MODE:
63- syslog('info', 'DlistUtils(setDisable):Executing query:\n%s\n Member whoes suppress value is to be found \n %s', command,member)
64- result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,"utf-8"))
65+ syslog('info', 'DlistUtils(setDisable):Executing query:\n%s\n Member whose suppress value is to be found \n %s', command, member)
66+ result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,"utf-8"))
67 oldval = [(subscriber.suppress) for subscriber in result]
68 if oldval == []:
69 if DEBUG_MODE:
70 syslog('info','oldval is an empty list.\nThis can happen either because of\n 1)Permission issues (Do a: bin/check_perms)\n 2)Inconsistency between database and pickle files (A user is in the database but not in pickle files or vice versa,Do a bin/find_problems.py)')
71 oldval = oldval[0]
72 if DEBUG_MODE:
73- syslog('info','the value of oldval is %s:',oldval)
74+ syslog('info','the value of oldval is %s:', oldval)
75
76 if flag:
77 newval = oldval | 1 # Disable delivery
78 else:
79 newval = oldval & ~1 # Enable delivery
80 if DEBUG_MODE:
81- syslog('info','the value of newval is %s:',newval)
82- command = "self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,'utf-8')).set(suppress = newval)\n"
83+ syslog('info','the value of newval is %s:', newval)
84+ command = "self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,'utf-8')).set(suppress = newval)\n"
85 if DEBUG_MODE:
86 syslog('info', 'DlistUtils(setDisable):Executing query:\n%s', command)
87- self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,"utf-8")).set(suppress = newval)
88+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,"utf-8")).set(suppress = newval)
89
90 @decfunc
91 def setDigest(self, member, flag):
92 """Disable/enable delivery based on user digest status"""
93
94- command = "result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,'utf-8'))\noldval = [(subscriber.suppress) for subscriber in result]\n"
95+ command = "result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,'utf-8'))\noldval = [(subscriber.suppress) for subscriber in result]\n"
96 if DEBUG_MODE:
97 syslog('info', 'DlistUtils(setDigest):Executing query:\n%s', command)
98- result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,"utf-8"))
99+ result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,"utf-8"))
100 oldval = [(subscriber.suppress) for subscriber in result]
101 if oldval == []:
102 if DEBUG_MODE:
103 syslog('info','oldval is an empty list.\nThis can happen either because of\n 1)permission issues (Do a: bin/check_perms)\n 2)Inconsistency between database and pickle files (A user is in the database but not in pickle files or vice versa,Do a bin/find_problems.py)')
104 oldval = oldval[0]
105 if DEBUG_MODE:
106- syslog('info','value of oldval %s:',oldval)
107+ syslog('info','value of oldval %s:', oldval)
108
109 if flag:
110 newval = oldval | 2 # Suppress delivery (in favor of digests)
111 else:
112 newval = oldval & ~2 # Enable delivery (instead of digests)
113
114- command = "self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,'utf-8')).set(suppress = newval)\n"
115+ command = "self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,'utf-8')).set(suppress = newval)\n"
116 if DEBUG_MODE:
117 syslog('info', 'DlistUtils(setDigest):Executing query:\n%s', command)
118- self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,"utf-8")).set(suppress = newval)
119+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,"utf-8")).set(suppress = newval)
120
121 @decfunc
122 def changePreference(self, member, preference):
123 """Change a user's default preference for new threads."""
124- command = "self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,'utf-8')).set(preference = preference)\n"
125+ command = "self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,'utf-8')).set(preference = preference)\n"
126 if DEBUG_MODE:
127 syslog('info', 'DlistUtils(changePreference):Executing query:\n%s', command)
128- self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,"utf-8")).set(preference = preference)
129+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,"utf-8")).set(preference = preference)
130
131 @decfunc
132 def changeFormat(self, member, format):
133 """Change a user's preferred delivery format (plain text and/or html)"""
134- command = "self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,'utf-8')).set(format = format)\n"
135+ command = "self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,'utf-8')).set(format = format)\n"
136 if DEBUG_MODE:
137 syslog('info', 'DlistUtils(changeFormat):Executing query:\n%s', command)
138- self.store.find(Subscriber,Subscriber.mailman_key == unicode(member,"utf-8")).set(format = format)
139+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(member,"utf-8")).set(format = format)
140
141 ### We have to watch out for a tricky case (that actually happened):
142 ### User foo@bar.com changes her address to something already in the
143@@ -207,32 +207,32 @@
144 @decfunc
145 def changeAddress(self, oldaddr, newaddr):
146 """Change email address in SQL database"""
147- #if DEBUG_MODE:
148- #syslog('info', "Changing email address on %s from '%s' to '%s'", self.mlist.internal_name(), oldaddr, newaddr)
149+ if DEBUG_MODE:
150+ syslog('info', "Changing email address on %s from '%s' to '%s'", self.mlist.internal_name(), oldaddr, newaddr)
151 ## Check if newaddr is in sql database
152- num_matches = self.store.find(Subscriber,Subscriber.mailman_key == unicode(newaddr,"utf-8")).count()
153+ num_matches = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(newaddr.lower(),"utf-8")).count()
154
155 if num_matches > 1:
156- #syslog('error', 'Multiple users with same key (%s): %s', self.mlist.internal_name(), newaddr)
157+ syslog('error', 'Multiple users with same key (%s): %s', self.mlist.internal_name(), newaddr)
158 return
159 if num_matches == 1:
160 self.mergeSubscribers(oldaddr, newaddr)
161
162- command = "num_matches = self.store.find(Subscriber,Subscriber.mailman_key == unicode(newaddr,'utf-8')).count()\nself.store.find(Subscriber,Subscriber.mailman_key == unicode(oldaddr,'utf-8')).set(mailman_key = unicode(newaddr,'utf-8'))\nself.store.find(Subscriber,Subscriber.mailman_key == unicode(newaddr,'utf-8')).set(deleted = False)\n"
163+ command = "num_matches = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(newaddr,'utf-8')).count()\nself.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(oldaddr,'utf-8')).set(mailman_key = unicode(newaddr,'utf-8'))\nself.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(newaddr.lower(),'utf-8')).set(deleted = False)\n"
164 if DEBUG_MODE:
165 syslog('info', 'DlistUtils(changeAddress):Executing query:\n%s', command)
166- self.store.find(Subscriber,Subscriber.mailman_key == unicode(oldaddr,"utf-8")).set(mailman_key = unicode(newaddr,"utf-8"))
167+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(oldaddr,"utf-8")).set(mailman_key = unicode(newaddr,"utf-8"))
168 self.store.commit()
169- self.store.find(Subscriber,Subscriber.mailman_key == unicode(newaddr,"utf-8")).set(deleted = False)
170+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(newaddr.lower(),"utf-8")).set(deleted = False)
171
172 @decfunc
173 def unsubscribeFromList(self, key):
174 """Indicate that a user has unsubscribed by setting the deleted flag in the subscriber table."""
175
176- command = "self.store.find(Subscriber,Subscriber.mailman_key == unicode(key,'utf-8')).set(deleted = True)\nself.store.find(Alias,Alias.subscriber_id == subscriber_id).remove()\n"
177+ command = "self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key,'utf-8')).set(deleted = True)\nself.store.find(Alias,Alias.subscriber_id == subscriber_id).remove()\n"
178 if DEBUG_MODE:
179 syslog('info', 'DlisUtils(unsubscribeFromList):Executing query:\n%s', command)
180- self.store.find(Subscriber,Subscriber.mailman_key == unicode(key,"utf-8")).set(deleted = True)
181+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key,"utf-8")).set(deleted = True)
182 # get the subscriber id from the mailman_key & delete all aliases
183 subscriber_id = self.getSubscriber_id_raw(key)
184
185@@ -245,20 +245,27 @@
186 def subscribeToList(self, key):
187 """Add a member to the subscriber database, or change the record from deleted if it was already present."""
188
189- command = "count = (self.store.find(Subscriber,Subscriber.mailman_key == unicode(key,'utf-8'))).count()\n"
190+ command = "count = (self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key.lower(),'utf-8'))).count()\n"
191 if DEBUG_MODE:
192 syslog('info', 'DlistUtils(subscribeToList):Executing query:\n%s', command)
193 # First see if member is subscribed with deleted field = false
194- count = (self.store.find(Subscriber,Subscriber.mailman_key == unicode(key,"utf-8"))).count()
195+ count = (self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key.lower(),"utf-8"))).count()
196
197 if count:
198- command = "self.store.find(Subscriber,Subscriber.mailman_key == unicode(key,'utf-8')).set(deleted = False)"
199+ command = "self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key.lower(),'utf-8')).set(deleted = False)"
200 if DEBUG_MODE:
201 syslog('info', 'DlistUtils(subscribeToList):Executing query:\n%s', command)
202- self.store.find(Subscriber,Subscriber.mailman_key == unicode(key,"utf-8")).set(deleted = False)
203+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key.lower(),"utf-8")).set(deleted = False)
204+
205+ result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key.lower(),"utf-8"))
206+ Email = [(subscriber.mailman_key) for subscriber in result]
207+ Email = Email[0]
208+ if Email != key: #That is if one was in lowercase and other in uppercase then update mailman_key with case sensitivity same as key
209+ self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(key.lower(),"utf-8")).set(mailman_key = unicode(key,"utf-8"))
210+
211 else:
212 # format is text-only (1) by default
213- command = "subscriber = self.store.add(Subscriber())\nsubscriber.mailman_key = unicode(key,'utf-8')\nsubscriber.preference = 1\nsubscriber.deleted = False\nsubscriber.format = 1\nsubscriber.suppress = 0"
214+ command = "subscriber = self.store.add(Subscriber())\nmailman_key = unicode(key,'utf-8')\npreference = 1\ndeleted = False\nformat = 1\nsuppress = 0"
215 if DEBUG_MODE:
216 syslog('info', 'DlistUtils(subscribeToList)Executing query:\n%s', command)
217 self.mailman_key = unicode(key,"utf-8")
218@@ -273,12 +280,12 @@
219 # use the original subscriber id as the ID going forward
220 if DEBUG_MODE:
221 syslog('info', 'Executing commands of mergeSubscribers:')
222- result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(oldaddr,"utf-8"))
223+ result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(oldaddr,"utf-8"))
224 new_id = [(subscriber.subscriber_id) for subscriber in result]
225 new_id = new_id[0]
226 if DEBUG_MODE:
227 syslog('info', 'the value of new_id: %s', new_id)
228- result = self.store.find(Subscriber,Subscriber.mailman_key == unicode(newaddr,"utf-8"))
229+ result = self.store.find(Subscriber,Subscriber.mailman_key.lower() == unicode(newaddr.lower(),"utf-8"))
230 obsolete_id = [(subscriber.subscriber_id) for subscriber in result]
231 obsolete_id = obsolete_id[0]
232 if DEBUG_MODE:
233@@ -291,13 +298,13 @@
234
235 class Message(object):
236 __storm_table__ = "message"
237- message_id = Int(primary = True,default = AutoReload)
238+ message_id = Int(primary = True, default = AutoReload)
239 sender_id = Int()
240- subscriber = Reference(sender_id,Subscriber.subscriber_id)
241+ subscriber = Reference(sender_id, Subscriber.subscriber_id)
242 subject = Unicode()
243 thread_id = Int()
244
245- def __init__(self,mlist):
246+ def __init__(self, mlist):
247 self.mlist = mlist
248 self.database = getConn(mlist)
249
250@@ -314,7 +321,7 @@
251 threadID = -1
252 command = "message = self.store.add(Message())\nmessage.sender_id = senderID\nmessage.thread_id = threadID\nmessage.subject = unicode(subject,'utf-8')\nmessageID = self.store.find(Message).max(Message.message_id)\n"
253 if DEBUG_MODE:
254- syslog('info','DlistUtils:(createMessage)executing query:\n%s',command)
255+ syslog('info','DlistUtils:(createMessage)executing query:\n%s', command)
256 #message_id has autoreload set,its value will be serially updated in database
257 self.sender_id = senderID
258 self.thread_id = threadID
259@@ -322,19 +329,19 @@
260 self.store.add(self)
261 messageID = self.store.find(Message).max(Message.message_id)
262 if DEBUG_MODE:
263- syslog('info','Result of query(messageID) is: %s\n',messageID)
264+ syslog('info','Result of query(messageID) is: %s\n', messageID)
265 return messageID
266
267 class Thread(object):
268 __storm_table__ = "thread"
269- thread_id = Int(primary = True,default = AutoReload)
270+ thread_id = Int(primary = True, default = AutoReload)
271 thread_name = Unicode()
272 base_message_id = Int()
273- message = Reference(base_message_id,Message.message_id)
274+ message = Reference(base_message_id, Message.message_id)
275 status = Int(default = 0)
276 parent = Int()
277
278- def __init__(self,mlist):
279+ def __init__(self, mlist):
280 self.mlist = mlist
281 self.database = getConn(mlist)
282
283@@ -347,7 +354,7 @@
284 senderID = subscriber.getSubscriber_id(msg, msgdata, safe=1, loose=1)
285 command = "thread = self.store.add(Thread())\nthread.base_message_id = msgdata['message_id']\nthreadID = self.store.find(Thread).max(Thread.thread_id)\nself.store.find(Message,Message.message_id == msgdata['message_id']).set(thread_id = threadID)\n"
286 if DEBUG_MODE:
287- syslog('info','DlistUtils:(createThread)executing query:\n%s',command)
288+ syslog('info','DlistUtils:(createThread)executing query:\n%s', command)
289 self.base_message_id = msgdata['message_id']
290 self.store.add(self)
291 threadID = self.store.find(Thread).max(Thread.thread_id)
292@@ -370,7 +377,7 @@
293 threadBase = threadBase[:13]
294 command = "num = self.store.find(Thread,Thread.thread_name == unicode(threadBase,'utf-8')).count()\nself.store.find(Thread,Thread.thread_id == threadID).set(thread_name = threadName)\n"
295 if DEBUG_MODE:
296- syslog('info','DlistUtils:(createThread)executing query:\n%s',command)
297+ syslog('info','DlistUtils:(createThread)executing query:\n%s', command)
298 # If the threadBase is not unique, make threadBase unique by appending a number
299 num = self.store.find(Thread,Thread.thread_name.like(unicode(threadBase + "%","utf-8"))).count()
300 if not num:
301@@ -405,26 +412,24 @@
302 msg['To'] = '%s+%s@%s' % (self.mlist.internal_name(),
303 name,
304 self.mlist.host_name)
305- for i in (1,2):
306+ for i in (1, 2):
307 # different footers for different prefs, so we need to queue separately
308 if(i==1):
309 #For condition where preference = True
310 pref=True
311- # command = "lists = [(subscriber.mailman_key.encode('utf-8')) for subscriber in result_new_sql]\n"
312- # if DEBUG_MODE:
313- # syslog('info', 'DlistUtils:(newThread)executing query:\n%sfor pref = true\n', command)
314+ if DEBUG_MODE:
315+ syslog('info', 'DlistUtils:(newThread)executing query:\nfor pref = true\n\n')
316 if(i==2):
317 #For condition where preference = False
318 pref=False
319- # command = "lists = [(subscriber.mailman_key.encode('utf-8')) for subscriber in result_new_sql]\n"
320- # if DEBUG_MODE:
321- # syslog('info', 'DlistUtils:(newThread)executing query:\n%sfor pref = false\n', command)
322+ if DEBUG_MODE:
323+ syslog('info', 'DlistUtils:(newThread)executing query:\nfor pref = false\n\n')
324
325 #Execute a SELECT statement, to find the list of matching subscribers.
326 result_new_sql = self.store.find(Subscriber,And(Subscriber.preference == pref,Subscriber.deleted == False,Subscriber.suppress == 0))
327 lists = [(subscriber.mailman_key.encode('utf-8')) for subscriber in result_new_sql]
328 if DEBUG_MODE:
329- syslog('info', 'value of lists: %s\n', lists)
330+ syslog('info','value of lists: %s\n', lists)
331 self.email_recipients(msg, msgdata, lists, pref)
332
333 # Make original message go to nobody (but be archived)
334@@ -514,12 +519,12 @@
335 override = Override(self.mlist)
336 override.override(msg, msgdata, 0)
337
338- def alphanumericOnly(self,s):
339+ def alphanumericOnly(self, s):
340 """Filter any non-letter characters from a string"""
341 result = [letter for letter in s if letter in string.ascii_letters or letter in string.digits]
342 return string.join(result, '')
343
344- def subjectToName(self,subject, threadID):
345+ def subjectToName(self, subject, threadID):
346 """Return a lower-case name for a new thread based on the subject, if present, or on the threadID"""
347 result = None
348
349@@ -589,9 +594,9 @@
350 __storm_table__ = "alias"
351 pseudonym = Unicode(primary = True)
352 subscriber_id = Int()
353- subscriber = Reference(subscriber_id,Subscriber.subscriber_id)
354+ subscriber = Reference(subscriber_id, Subscriber.subscriber_id)
355
356- def __init__(self,mlist):
357+ def __init__(self, mlist):
358 self.mlist = mlist
359 self.database = getConn(mlist)
360
361@@ -604,8 +609,8 @@
362 syslog('info', 'DlistUtils(canonicalize_sender)Executing query:\n%s', command)
363
364 for alias in aliases:
365- #if DEBUG_MODE:
366- #syslog('info', 'Checking if <%s> is an alias', alias)
367+ if DEBUG_MODE:
368+ syslog('info', 'Checking if <%s> is an alias', alias)
369 result = self.store.find((Subscriber,Alias),And(Alias.pseudonym == unicode(alias,'utf-8'),Subscriber.subscriber_id == Alias.subscriber_id))
370 lists = [(subscriber.mailman_key.encode('utf-8')) for (subscriber,alias) in result]
371
372@@ -654,12 +659,12 @@
373 __storm_table__ = "override"
374 __storm_primary__ = "subscriber_id", "thread_id"
375 subscriber_id = Int()
376- subscriber = Reference(subscriber_id,Subscriber.subscriber_id)
377+ subscriber = Reference(subscriber_id, Subscriber.subscriber_id)
378 thread_id = Int()
379- thread = Reference(thread_id,Thread.thread_id)
380+ thread = Reference(thread_id, Thread.thread_id)
381 preference = Int()
382
383- def __init__(self,mlist):
384+ def __init__(self, mlist):
385 self.mlist = mlist
386 self.database = getConn(mlist)
387
388@@ -709,10 +714,9 @@
389
390 return 1
391
392- def overrideURL(self,list_name, host_name, thread_reference, preference):
393+ def overrideURL(self, list_name, host_name, thread_reference, preference):
394 return 'http://%s/mailman/options/%s?override=%s&preference=%d' % (host_name, list_name, thread_reference, preference)
395
396-
397 #Functions Independent of the database tables in DlistUtils
398
399 def GetEmailAddresses(mlist, subscribers):
400@@ -752,13 +756,22 @@
401
402 def _create_database(name):
403 """Create a database. This requires us to not be in a transaction."""
404- conn = pgdb.connect(host='localhost', database='postgres',user='mailman', password='mailman')
405+ conn = pgdb.connect(host='localhost', database='postgres', user='mailman', password='mailman')
406 old_iso_lvl = conn.isolation_level
407 conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
408 cursor = conn.cursor()
409 cursor.execute('create database "%s"' % name)
410 conn.set_isolation_level(old_iso_lvl)
411
412+def _remove_database(name):
413+ """Remove a database. This requires us to not be in a transaction."""
414+ conn = pgdb.connect(host='localhost', database='postgres', user='mailman', password='mailman')
415+ old_iso_lvl = conn.isolation_level
416+ conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
417+ cursor = conn.cursor()
418+ cursor.execute('DROP DATABASE "%s"' % name)
419+ conn.set_isolation_level(old_iso_lvl)
420+
421 def executeSQL(mlist, commands):
422 """Execute a sequence of SQL commands that create tables in the database."""
423 database = getConn(mlist)
424@@ -834,3 +847,9 @@
425 mlist.Save()
426 if alreadyLocked == 0:
427 mlist.Unlock()
428+
429+def remove_dlist(listname):
430+ """ Deletes the corresponding postgres database and tables."""
431+ _remove_database(listname)
432+ if DEBUG_MODE:
433+ syslog('info', "Database %s removed\n", listname)
434
435=== modified file 'Mailman/mm_cfg.py'
436--- Mailman/mm_cfg.py 2010-01-31 20:29:48 +0000
437+++ Mailman/mm_cfg.py 2010-05-28 04:55:39 +0000
438@@ -68,4 +68,4 @@
439 STORM_DB_HOST = "localhost"
440
441 # Variable to write more to the logs when in debugging mode (currently only used for the info-logs). Set to False in production mode.
442-DEBUG_MODE = True
443+DEBUG_MODE = False
444
445=== modified file 'bin/rmlist'
446--- bin/rmlist 2009-07-31 10:49:01 +0000
447+++ bin/rmlist 2010-05-28 04:55:39 +0000
448@@ -152,12 +152,7 @@
449
450 # Remove the database in PostgreSQL if it was a dynamic list. Added by Systers.
451 try:
452- conn = DlistUtils.getConn(None)
453- old_iso_lvl = conn.isolation_level
454- conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
455- cursor = conn.cursor()
456- cursor.execute('DROP DATABASE "%s"' % listname)
457- conn.set_isolation_level(old_iso_lvl)
458+ DlistUtils.remove_dlist(listname)
459 except:
460 syslog('error', 'Tried to remove the database for %s, no such database (ok if it was a non dlist). If it was a dlist, the postgreSQL database for this list needs to be removed manually.' % listname)
461

Subscribers

People subscribed via source and target branches