Skip to content

Commit 37c0c63

Browse files
author
Richard Jones
committed
Fixed issues with nosy reaction and author copies.
1 parent 6a85324 commit 37c0c63

File tree

7 files changed

+123
-59
lines changed

7 files changed

+123
-59
lines changed

roundup-admin

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup-admin,v 1.43 2001-11-09 22:33:28 richard Exp $
19+
# $Id: roundup-admin,v 1.44 2001-11-12 22:01:06 richard Exp $
2020

2121
import sys
2222
if int(sys.version[0]) < 2:
@@ -64,6 +64,7 @@ class AdminTool:
6464
for k in AdminTool.__dict__.keys():
6565
if k[:5] == 'help_':
6666
self.help[k[5:]] = getattr(self, k)
67+
self.db = None
6768

6869
def usage(message=''):
6970
if message: message = 'Problem: '+message+'\n'
@@ -799,11 +800,15 @@ Command help:
799800
self.instance_home = raw_input('Enter instance home: ').strip()
800801

801802
# before we open the db, we may be doing an init
802-
if command == 'init':
803-
return self.do_init(self.instance_home, args)
803+
if command == 'initialise':
804+
return self.do_initialise(self.instance_home, args)
804805

805806
# get the instance
806-
instance = roundup.instance.open(self.instance_home)
807+
try:
808+
instance = roundup.instance.open(self.instance_home)
809+
except ValueError, message:
810+
print "Couldn't open instance: %s"%message
811+
return 1
807812
self.db = instance.open('admin')
808813

809814
if len(args) < 2:
@@ -872,7 +877,8 @@ Command help:
872877
self.interactive()
873878
else:
874879
ret = self.run_command(args)
875-
self.db.close()
880+
if self.db:
881+
self.db.close()
876882
return ret
877883

878884

@@ -882,6 +888,9 @@ if __name__ == '__main__':
882888

883889
#
884890
# $Log: not supported by cvs2svn $
891+
# Revision 1.43 2001/11/09 22:33:28 richard
892+
# More error handling fixes.
893+
#
885894
# Revision 1.42 2001/11/09 10:11:08 richard
886895
# . roundup-admin now handles all hyperdb exceptions
887896
#

roundup/hyperdb.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: hyperdb.py,v 1.30 2001-11-09 10:11:08 richard Exp $
18+
# $Id: hyperdb.py,v 1.31 2001-11-12 22:01:06 richard Exp $
1919

2020
# standard python modules
2121
import cPickle, re, string
@@ -545,7 +545,7 @@ def stringFind(self, **requirements):
545545
if node.has_key(self.db.RETIRED_FLAG):
546546
continue
547547
for key, value in requirements.items():
548-
if node[key].lower() != value:
548+
if node[key] and node[key].lower() != value:
549549
break
550550
else:
551551
l.append(nodeid)
@@ -849,6 +849,9 @@ def Choice(name, *options):
849849

850850
#
851851
# $Log: not supported by cvs2svn $
852+
# Revision 1.30 2001/11/09 10:11:08 richard
853+
# . roundup-admin now handles all hyperdb exceptions
854+
#
852855
# Revision 1.29 2001/10/27 00:17:41 richard
853856
# Made Class.stringFind() do caseless matching.
854857
#

roundup/instance.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: instance.py,v 1.3 2001-08-07 00:24:42 richard Exp $
18+
# $Id: instance.py,v 1.4 2001-11-12 22:01:06 richard Exp $
1919

2020
''' Currently this module provides one function: open. This function opens
2121
an instance.
2222
'''
2323

24-
import imp
24+
import imp, os
2525

2626
class Opener:
2727
def __init__(self):
2828
self.number = 0
2929
self.instances = {}
3030

3131
def open(self, instance_home):
32+
'''Open the instance.
33+
34+
Raise ValueError if the instance home doesn't exist.
35+
'''
36+
if not os.path.exists(instance_home):
37+
raise ValueError, 'no such directory: "%s"'%instance_home
3238
if self.instances.has_key(instance_home):
3339
return imp.load_package(self.instances[instance_home],
3440
instance_home)
@@ -46,6 +52,9 @@ def open(self, instance_home):
4652

4753
#
4854
# $Log: not supported by cvs2svn $
55+
# Revision 1.3 2001/08/07 00:24:42 richard
56+
# stupid typo
57+
#
4958
# Revision 1.2 2001/08/07 00:15:51 richard
5059
# Added the copyright/license notice to (nearly) all files at request of
5160
# Bizar Software.

roundup/mailgw.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class node. Any parts of other types are each stored in separate files
7272
an exception, the original message is bounced back to the sender with the
7373
explanatory message given in the exception.
7474
75-
$Id: mailgw.py,v 1.30 2001-11-09 22:33:28 richard Exp $
75+
$Id: mailgw.py,v 1.31 2001-11-12 22:01:06 richard Exp $
7676
'''
7777

7878

@@ -138,7 +138,8 @@ def handle_Message(self, message):
138138
if sendto:
139139
try:
140140
self.handle_message(message)
141-
return
141+
sendto = [sendto[0][1]]
142+
m = ['Subject: Well, it seemed to work', '', 'hi, mum!']
142143
except MailUsageError, value:
143144
# bounce the message back to the sender with the usage message
144145
fulldoc = '\n'.join(string.split(__doc__, '\n')[2:])
@@ -150,8 +151,7 @@ def handle_Message(self, message):
150151
except:
151152
# bounce the message back to the sender with the error message
152153
sendto = [sendto[0][1]]
153-
m = ['Subject: failed issue tracker submission']
154-
m.append('')
154+
m = ['Subject: failed issue tracker submission', '']
155155
# TODO as attachments?
156156
m.append('---- traceback of failure ----')
157157
s = cStringIO.StringIO()
@@ -516,6 +516,9 @@ def parseContent(content, blank_line=re.compile(r'[\r\n]+\s*[\r\n]+'),
516516

517517
#
518518
# $Log: not supported by cvs2svn $
519+
# Revision 1.30 2001/11/09 22:33:28 richard
520+
# More error handling fixes.
521+
#
519522
# Revision 1.29 2001/11/07 05:29:26 richard
520523
# Modified roundup-mailgw so it can read e-mails from a local mail spool
521524
# file. Truncates the spool file after parsing.

roundup/roundupdb.py

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.16 2001-10-30 00:54:45 richard Exp $
18+
# $Id: roundupdb.py,v 1.17 2001-11-12 22:01:06 richard Exp $
1919

2020
import re, os, smtplib, socket
2121

@@ -31,6 +31,7 @@ def splitDesignator(designator, dre=re.compile(r'([^\d]+)(\d+)')):
3131
raise DesignatorError, '"%s" not a node designator'%designator
3232
return m.group(1), m.group(2)
3333

34+
3435
class Database:
3536
def getuid(self):
3637
"""Return the id of the "user" node associated with the user
@@ -214,6 +215,12 @@ def getprops(self, protected=1):
214215
d['content'] = hyperdb.String()
215216
return d
216217

218+
class MessageSendError(RuntimeError):
219+
pass
220+
221+
class DetectorError(RuntimeError):
222+
pass
223+
217224
# XXX deviation from spec - was called ItemClass
218225
class IssueClass(Class):
219226
# configuration
@@ -266,17 +273,18 @@ def sendmessage(self, nodeid, msgid):
266273
r = {}
267274
for recipid in recipients:
268275
r[recipid] = 1
276+
rlen = len(recipients)
269277

270278
# figure the author's id, and indicate they've received the message
271279
authid = self.db.msg.get(msgid, 'author')
272-
r[authid] = 1
273280

274-
sendto = []
275281
# ... but duplicate the message to the author as long as it's not
276282
# the anonymous user
277283
if (self.MESSAGES_TO_AUTHOR == 'yes' and
278284
self.db.user.get(authid, 'username') != 'anonymous'):
279-
sendto.append(authid)
285+
if not r.has_key(authid):
286+
recipients.append(authid)
287+
r[authid] = 1
280288

281289
# now figure the nosy people who weren't recipients
282290
nosy = self.get(nodeid, 'nosy')
@@ -286,46 +294,50 @@ def sendmessage(self, nodeid, msgid):
286294
# do...)
287295
if self.db.user.get(nosyid, 'username') == 'anonymous': continue
288296
if not r.has_key(nosyid):
289-
sendto.append(nosyid)
290297
recipients.append(nosyid)
291298

292-
if sendto:
293-
# update the message's recipients list
294-
self.db.msg.set(msgid, recipients=recipients)
295-
296-
# send an email to the people who missed out
297-
sendto = [self.db.user.get(i, 'address') for i in recipients]
298-
cn = self.classname
299-
title = self.get(nodeid, 'title') or '%s message copy'%cn
300-
# figure author information
301-
authname = self.db.user.get(authid, 'realname')
302-
if not authname:
303-
authname = self.db.user.get(authid, 'username')
304-
authaddr = self.db.user.get(authid, 'address')
305-
if authaddr:
306-
authaddr = '<%s> '%authaddr
307-
else:
308-
authaddr = ''
309-
# TODO attachments
310-
m = ['Subject: [%s%s] %s'%(cn, nodeid, title)]
311-
m.append('To: %s'%', '.join(sendto))
312-
m.append('From: %s'%self.ISSUE_TRACKER_EMAIL)
313-
m.append('Reply-To: %s'%self.ISSUE_TRACKER_EMAIL)
314-
m.append('')
315-
# add author information
316-
m.append("%s %sadded the comment:"%(authname, authaddr))
317-
m.append('')
318-
# add the content
319-
m.append(self.db.msg.get(msgid, 'content'))
320-
# "list information" footer
321-
m.append(self.email_footer(nodeid, msgid))
322-
try:
323-
smtp = smtplib.SMTP(self.MAILHOST)
324-
smtp.sendmail(self.ISSUE_TRACKER_EMAIL, sendto, '\n'.join(m))
325-
except socket.error, value:
326-
return "Couldn't send confirmation email: mailhost %s"%value
327-
except smtplib.SMTPException, value:
328-
return "Couldn't send confirmation email: %s"%value
299+
# no new recipients
300+
if rlen == len(recipients):
301+
return
302+
303+
# update the message's recipients list
304+
self.db.msg.set(msgid, recipients=recipients)
305+
306+
# send an email to the people who missed out
307+
sendto = [self.db.user.get(i, 'address') for i in recipients]
308+
cn = self.classname
309+
title = self.get(nodeid, 'title') or '%s message copy'%cn
310+
# figure author information
311+
authname = self.db.user.get(authid, 'realname')
312+
if not authname:
313+
authname = self.db.user.get(authid, 'username')
314+
authaddr = self.db.user.get(authid, 'address')
315+
if authaddr:
316+
authaddr = '<%s> '%authaddr
317+
else:
318+
authaddr = ''
319+
# TODO attachments
320+
m = ['Subject: [%s%s] %s'%(cn, nodeid, title)]
321+
m.append('To: %s'%', '.join(sendto))
322+
m.append('From: %s'%self.ISSUE_TRACKER_EMAIL)
323+
m.append('Reply-To: %s'%self.ISSUE_TRACKER_EMAIL)
324+
m.append('')
325+
# add author information
326+
m.append("%s %sadded the comment:"%(authname, authaddr))
327+
m.append('')
328+
# add the content
329+
m.append(self.db.msg.get(msgid, 'content'))
330+
# "list information" footer
331+
m.append(self.email_footer(nodeid, msgid))
332+
try:
333+
smtp = smtplib.SMTP(self.MAILHOST)
334+
smtp.sendmail(self.ISSUE_TRACKER_EMAIL, sendto, '\n'.join(m))
335+
except socket.error, value:
336+
raise MessageSendError, \
337+
"Couldn't send confirmation email: mailhost %s"%value
338+
except smtplib.SMTPException, value:
339+
raise MessageSendError, \
340+
"Couldn't send confirmation email: %s"%value
329341

330342
def email_footer(self, nodeid, msgid):
331343
''' Add a footer to the e-mail with some useful information
@@ -339,6 +351,12 @@ def email_footer(self, nodeid, msgid):
339351

340352
#
341353
# $Log: not supported by cvs2svn $
354+
# Revision 1.16 2001/10/30 00:54:45 richard
355+
# Features:
356+
# . #467129 ] Lossage when username=e-mail-address
357+
# . #473123 ] Change message generation for author
358+
# . MailGW now moves 'resolved' to 'chatting' on receiving e-mail for an issue.
359+
#
342360
# Revision 1.15 2001/10/23 01:00:18 richard
343361
# Re-enabled login and registration access after lopping them off via
344362
# disabling access for anonymous users.

roundup/templates/classic/detectors/nosyreaction.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.4 2001-10-30 00:54:45 richard Exp $
18+
#$Id: nosyreaction.py,v 1.5 2001-11-12 22:01:07 richard Exp $
19+
20+
from roundup import roundupdb
1921

2022
def nosyreaction(db, cl, nodeid, oldvalues):
2123
''' A standard detector is provided that watches for additions to the
@@ -51,7 +53,10 @@ def nosyreaction(db, cl, nodeid, oldvalues):
5153

5254
# send a copy to the nosy list
5355
for msgid in messages:
54-
cl.sendmessage(nodeid, msgid)
56+
try:
57+
cl.sendmessage(nodeid, msgid)
58+
except roundupdb.MessageSendError, message:
59+
raise roundupdb.DetectorError, message
5560

5661
# update the nosy list with the recipients from the new messages
5762
nosy = cl.get(nodeid, 'nosy')
@@ -82,6 +87,12 @@ def init(db):
8287

8388
#
8489
#$Log: not supported by cvs2svn $
90+
#Revision 1.4 2001/10/30 00:54:45 richard
91+
#Features:
92+
# . #467129 ] Lossage when username=e-mail-address
93+
# . #473123 ] Change message generation for author
94+
# . MailGW now moves 'resolved' to 'chatting' on receiving e-mail for an issue.
95+
#
8596
#Revision 1.3 2001/08/07 00:24:43 richard
8697
#stupid typo
8798
#

roundup/templates/extended/detectors/nosyreaction.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: nosyreaction.py,v 1.4 2001-10-30 00:54:45 richard Exp $
18+
#$Id: nosyreaction.py,v 1.5 2001-11-12 22:01:07 richard Exp $
19+
20+
from roundup import roundupdb
1921

2022
def nosyreaction(db, cl, nodeid, oldvalues):
2123
''' A standard detector is provided that watches for additions to the
@@ -51,7 +53,10 @@ def nosyreaction(db, cl, nodeid, oldvalues):
5153

5254
# send a copy to the nosy list
5355
for msgid in messages:
54-
cl.sendmessage(nodeid, msgid)
56+
try:
57+
cl.sendmessage(nodeid, msgid)
58+
except roundupdb.MessageSendError, message:
59+
raise roundupdb.DetectorError, message
5560

5661
# update the nosy list with the recipients from the new messages
5762
nosy = cl.get(nodeid, 'nosy')
@@ -82,6 +87,12 @@ def init(db):
8287

8388
#
8489
#$Log: not supported by cvs2svn $
90+
#Revision 1.4 2001/10/30 00:54:45 richard
91+
#Features:
92+
# . #467129 ] Lossage when username=e-mail-address
93+
# . #473123 ] Change message generation for author
94+
# . MailGW now moves 'resolved' to 'chatting' on receiving e-mail for an issue.
95+
#
8596
#Revision 1.3 2001/08/07 00:24:43 richard
8697
#stupid typo
8798
#

0 commit comments

Comments
 (0)