Mercurial > p > roundup > code
comparison roundup/mailgw.py @ 1592:4074e2336eed
fixes to unit tests for recent changes
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 17 Apr 2003 06:51:44 +0000 |
| parents | 21312a7564fd |
| children | f2bdf6b07c2a |
comparison
equal
deleted
inserted
replaced
| 1591:21312a7564fd | 1592:4074e2336eed |
|---|---|
| 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.115 2003-04-17 03:37:59 richard Exp $ | 76 $Id: mailgw.py,v 1.116 2003-04-17 06:51:44 richard Exp $ |
| 77 ''' | 77 ''' |
| 78 | 78 |
| 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri | 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri |
| 80 import time, random, sys | 80 import time, random, sys |
| 81 import traceback, MimeWriter, rfc822 | 81 import traceback, MimeWriter, rfc822 |
| 1022 # submissions where the address is empty) | 1022 # submissions where the address is empty) |
| 1023 user = extractUserFromList(db.user, db.user.stringFind(username=address)) | 1023 user = extractUserFromList(db.user, db.user.stringFind(username=address)) |
| 1024 | 1024 |
| 1025 # couldn't match address or username, so create a new user | 1025 # couldn't match address or username, so create a new user |
| 1026 if create: | 1026 if create: |
| 1027 return db.user.create(username=address, address=address, | 1027 # generate a username |
| 1028 if '@' in address: | |
| 1029 username = address.split('@')[0] | |
| 1030 else: | |
| 1031 username = address | |
| 1032 trying = username | |
| 1033 n = 0 | |
| 1034 while 1: | |
| 1035 try: | |
| 1036 # does this username exist already? | |
| 1037 db.user.lookup(trying) | |
| 1038 except KeyError: | |
| 1039 break | |
| 1040 n += 1 | |
| 1041 trying = username + str(n) | |
| 1042 | |
| 1043 # create! | |
| 1044 return db.user.create(username=trying, address=address, | |
| 1028 realname=realname, roles=db.config.NEW_EMAIL_USER_ROLES, | 1045 realname=realname, roles=db.config.NEW_EMAIL_USER_ROLES, |
| 1029 password=password.Password(password.generatePassword()), | 1046 password=password.Password(password.generatePassword()), |
| 1030 **user_props) | 1047 **user_props) |
| 1031 else: | 1048 else: |
| 1032 return 0 | 1049 return 0 |
