Mercurial > p > roundup > code
diff roundup/mailgw.py @ 560:d7b9751f8927
Mail gateway improvements.
Feature:
. the mail gateway now responds with an error message when invalid
values for arguments are specified for link or multilink properties
. modified unit test to check nosy and assignedto when specified as
arguments
Fixed:
. fixed setting nosy as argument in subject line
| author | Roche Compaan <rochecompaan@users.sourceforge.net> |
|---|---|
| date | Mon, 21 Jan 2002 10:05:48 +0000 |
| parents | d276d72ebdaf |
| children | 2998d683e2cf |
line wrap: on
line diff
--- a/roundup/mailgw.py Mon Jan 21 09:55:14 2002 +0000 +++ b/roundup/mailgw.py Mon Jan 21 10:05:48 2002 +0000 @@ -73,7 +73,7 @@ an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.54 2002-01-16 09:14:45 grubert Exp $ +$Id: mailgw.py,v 1.55 2002-01-21 10:05:47 rochecompaan Exp $ ''' @@ -387,15 +387,32 @@ Subject was: "%s" '''%(key, message, subject) elif isinstance(proptype, hyperdb.Link): - link = self.db.classes[proptype.classname] - propkey = link.labelprop(default_to_id=1) - props[key] = value + linkcl = self.db.classes[proptype.classname] + propkey = linkcl.labelprop(default_to_id=1) + try: + props[key] = linkcl.lookup(value) + except KeyError, message: + raise MailUsageError, ''' +Subject argument list contains an invalid value for %s. + +Error was: %s +Subject was: "%s" +'''%(key, message, subject) elif isinstance(proptype, hyperdb.Multilink): # get the linked class linkcl = self.db.classes[proptype.classname] propkey = linkcl.labelprop(default_to_id=1) for item in value.split(','): - item = item.split() + item = item.strip() + try: + item = linkcl.lookup(item) + except KeyError, message: + raise MailUsageError, ''' +Subject argument list contains an invalid value for %s. + +Error was: %s +Subject was: "%s" +'''%(key, message, subject) if props.has_key(key): props[key].append(item) else: @@ -582,12 +599,10 @@ n[nid] = 1 props['nosy'] = n.keys() # add assignedto to the nosy list - try: - assignedto = self.db.user.lookup(props['assignedto']) + if props.has_key('assignedto'): + assignedto = props['assignedto'] if assignedto not in props['nosy']: props['nosy'].append(assignedto) - except: - pass message_id = self.db.msg.create(author=author, recipients=recipients, date=date.Date('.'), summary=summary, @@ -646,10 +661,7 @@ nosy = props.get('nosy', []) n = {} for value in nosy: - if self.db.hasnode('user', value): - nid = value - else: - continue + nid = value if n.has_key(nid): continue n[nid] = 1 props['nosy'] = n.keys() @@ -667,14 +679,6 @@ # add assignedto to the nosy list if properties.has_key('assignedto') and props.has_key('assignedto'): assignedto = props['assignedto'] - if not re.match('^\d+$', assignedto): - try: - assignedto = self.db.user.lookup(assignedto) - except KeyError: - raise MailUsageError, ''' -There was a problem with the message you sent: - Assignedto user '%s' doesn't exist -'''%props['assignedto'] if not n.has_key(assignedto): props['nosy'].append(assignedto) n[assignedto] = 1 @@ -749,6 +753,9 @@ # # $Log: not supported by cvs2svn $ +# Revision 1.54 2002/01/16 09:14:45 grubert +# . if the attachment has no name, name it unnamed, happens with tnefs. +# # Revision 1.53 2002/01/16 07:20:54 richard # simple help command for mailgw #
