comparison roundup/mailgw.py @ 537:ad6dbc21a570

[SF#503340] creating issue with [asignedto=p.ohly]
author Richard Jones <richard@users.sourceforge.net>
date Tue, 15 Jan 2002 00:12:40 +0000
parents dce4c75bef5a
children d32977eb8bd4
comparison
equal deleted inserted replaced
536:8298fea69bc3 537:ad6dbc21a570
71 set() method to add the message to the item's spool; in the second case we 71 set() method to add the message to the item's spool; in the second case we
72 are calling the create() method to create a new node). If an auditor raises 72 are calling the create() method to create a new node). If an auditor raises
73 an exception, the original message is bounced back to the sender with the 73 an exception, the original message is bounced back to the sender with the
74 explanatory message given in the exception. 74 explanatory message given in the exception.
75 75
76 $Id: mailgw.py,v 1.51 2002-01-14 02:20:15 richard Exp $ 76 $Id: mailgw.py,v 1.52 2002-01-15 00:12:40 richard Exp $
77 ''' 77 '''
78 78
79 79
80 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri 80 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
81 import time, random 81 import time, random
321 321
322 # handle the args 322 # handle the args
323 args = m.group('args') 323 args = m.group('args')
324 if args: 324 if args:
325 for prop in string.split(args, ';'): 325 for prop in string.split(args, ';'):
326 # extract the property name and value
326 try: 327 try:
327 key, value = prop.split('=') 328 key, value = prop.split('=')
328 except ValueError, message: 329 except ValueError, message:
329 raise MailUsageError, ''' 330 raise MailUsageError, '''
330 Subject argument list not of form [arg=value,value,...;arg=value,value...] 331 Subject argument list not of form [arg=value,value,...;arg=value,value...]
331 (specific exception message was "%s") 332 (specific exception message was "%s")
332 333
333 Subject was: "%s" 334 Subject was: "%s"
334 '''%(message, subject) 335 '''%(message, subject)
336
337 # ensure it's a valid property name
335 key = key.strip() 338 key = key.strip()
336 try: 339 try:
337 proptype = properties[key] 340 proptype = properties[key]
338 except KeyError: 341 except KeyError:
339 raise MailUsageError, ''' 342 raise MailUsageError, '''
340 Subject argument list refers to an invalid property: "%s" 343 Subject argument list refers to an invalid property: "%s"
341 344
342 Subject was: "%s" 345 Subject was: "%s"
343 '''%(key, subject) 346 '''%(key, subject)
347
348 # convert the string value to a real property value
344 if isinstance(proptype, hyperdb.String): 349 if isinstance(proptype, hyperdb.String):
345 props[key] = value.strip() 350 props[key] = value.strip()
346 if isinstance(proptype, hyperdb.Password): 351 if isinstance(proptype, hyperdb.Password):
347 props[key] = password.Password(value.strip()) 352 props[key] = password.Password(value.strip())
348 elif isinstance(proptype, hyperdb.Date): 353 elif isinstance(proptype, hyperdb.Date):
366 Subject was: "%s" 371 Subject was: "%s"
367 '''%(key, message, subject) 372 '''%(key, message, subject)
368 elif isinstance(proptype, hyperdb.Link): 373 elif isinstance(proptype, hyperdb.Link):
369 link = self.db.classes[proptype.classname] 374 link = self.db.classes[proptype.classname]
370 propkey = link.labelprop(default_to_id=1) 375 propkey = link.labelprop(default_to_id=1)
371 try: 376 props[key] = value
372 props[key] = link.get(value.strip(), propkey)
373 except:
374 props[key] = link.lookup(value.strip())
375 elif isinstance(proptype, hyperdb.Multilink): 377 elif isinstance(proptype, hyperdb.Multilink):
376 link = self.db.classes[proptype.classname] 378 # get the linked class
377 propkey = link.labelprop(default_to_id=1) 379 linkcl = self.db.classes[proptype.classname]
378 l = [x.strip() for x in value.split(',')] 380 propkey = linkcl.labelprop(default_to_id=1)
379 for item in l: 381 for item in value.split(','):
380 try: 382 item = item.split()
381 v = link.get(item, propkey)
382 except:
383 v = link.lookup(item)
384 if props.has_key(key): 383 if props.has_key(key):
385 props[key].append(v) 384 props[key].append(item)
386 else: 385 else:
387 props[key] = [v] 386 props[key] = [item]
388 387
389 # 388 #
390 # handle the users 389 # handle the users
391 # 390 #
392 391
647 props['nosy'].append(author) 646 props['nosy'].append(author)
648 n[author] = 1 647 n[author] = 1
649 648
650 # add assignedto to the nosy list 649 # add assignedto to the nosy list
651 if properties.has_key('assignedto') and props.has_key('assignedto'): 650 if properties.has_key('assignedto') and props.has_key('assignedto'):
652 try: 651 assignedto = props['assignedto']
653 assignedto = self.db.user.lookup(props['assignedto']) 652 if not re.match('^\d+$', assignedto):
654 except KeyError: 653 try:
655 raise MailUsageError, ''' 654 assignedto = self.db.user.lookup(assignedto)
655 except KeyError:
656 raise MailUsageError, '''
656 There was a problem with the message you sent: 657 There was a problem with the message you sent:
657 Assignedto user '%s' doesn't exist 658 Assignedto user '%s' doesn't exist
658 '''%props['assignedto'] 659 '''%props['assignedto']
659 if not n.has_key(assignedto): 660 if not n.has_key(assignedto):
660 props['nosy'].append(assignedto) 661 props['nosy'].append(assignedto)
728 l.append(section) 729 l.append(section)
729 return summary, '\n\n'.join(l) 730 return summary, '\n\n'.join(l)
730 731
731 # 732 #
732 # $Log: not supported by cvs2svn $ 733 # $Log: not supported by cvs2svn $
734 # Revision 1.51 2002/01/14 02:20:15 richard
735 # . changed all config accesses so they access either the instance or the
736 # config attriubute on the db. This means that all config is obtained from
737 # instance_config instead of the mish-mash of classes. This will make
738 # switching to a ConfigParser setup easier too, I hope.
739 #
740 # At a minimum, this makes migration a _little_ easier (a lot easier in the
741 # 0.5.0 switch, I hope!)
742 #
733 # Revision 1.50 2002/01/11 22:59:01 richard 743 # Revision 1.50 2002/01/11 22:59:01 richard
734 # . #502342 ] pipe interface 744 # . #502342 ] pipe interface
735 # 745 #
736 # Revision 1.49 2002/01/10 06:19:18 richard 746 # Revision 1.49 2002/01/10 06:19:18 richard
737 # followup lines directly after a quoted section were being eaten. 747 # followup lines directly after a quoted section were being eaten.

Roundup Issue Tracker: http://roundup-tracker.org/