I'm not sure how best to go about making submissions to the code base, so
I'll submit the diffs.

I'm using TMDA/1.0.2 "Bold Forbes" (Python/2.2.3 on linux-i686)

I wanted to be able to exclusively use a database backend for list
management.  To achieve this goal I needed to have DB_ analogs of the
PENDING_*_APPEND config variables.  To that end, I modded Defaults.py and
Pending.py with a little cut and paste work from tmda-rfilter.  A diff file
of my changes is attached.  Is their a better/more preferred method of
submitting changes?
 
The result is I'm now able to use the DB_PENDING_*_APPEND config variables
to insert into my database.  I only seem to have one problem, though I am
able to work around it.  Using MySQL as the backend database, if I don't use
the INSERT IGNORE INTO table ... Syntax and just use INSERT INTO ... I get
the following traceback when I attempt to insert a duplicate key which
surprises me since the db_insert function in Util.py looks like it should be
catching "DatabaseError"s of which _mysql_exceptions.IntegrityError appears
to be a subclass of:

Traceback (most recent call last):
  File "/usr/bin/tmda-pending", line 311, in ?
    main()
  File "/usr/bin/tmda-pending", line 304, in main
    q.mainLoop()
  File "/usr/lib/python2.2/site-packages/TMDA/Pending.py", line 319, in
mainLoop
    if not self.disposeMessage(M):
  File "/usr/lib/python2.2/site-packages/TMDA/Pending.py", line 253, in
disposeMessage
    M.delete()
  File "/usr/lib/python2.2/site-packages/TMDA/Pending.py", line 499, in
delete
    params)
  File "/usr/lib/python2.2/site-packages/TMDA/Util.py", line 763, in
db_insert
    cursor.execute(insert_sql, params)
  File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 66, in
execute
    r = self._query(query % self.__conn.literal(args))
  File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 168, in
_query
    rowcount = self._BaseCursor__do_query(q)
  File "/usr/lib/python2.2/site-packages/MySQLdb/cursors.py", line 112, in
__do_query
    db.query(q)
_mysql_exceptions.IntegrityError: (1062, "Duplicate entry
'[EMAIL PROTECTED]' for key 1")



Thanks for TMDA, it's a great product,

Dave
[> diff Defaults.py Defaults.py-orig
1096,1107d1095
< if not vars().has_key('DB_PENDING_BLACKLIST_APPEND'):
<     DB_PENDING_BLACKLIST_APPEND = None
< 
< if not vars().has_key('DB_PENDING_WHITELIST_APPEND'):
<     DB_PENDING_WHITELIST_APPEND = None
< 
< if not vars().has_key('DB_PENDING_DELETE_APPEND'):
<     DB_PENDING_DELETE_APPEND = None
< 
< if not vars().has_key('DB_PENDING_RELEASE_APPEND'):
<     DB_PENDING_RELEASE_APPEND = None
< 

[> diff Pending.py Pending.py-orig
36d35
< import FilterParser
217,227d215
<             if Defaults.DB_PENDING_DELETE_APPEND and Defaults.DB_CONNECTION:
<                 _username = Defaults.USERNAME.lower()
<                 _hostname = Defaults.HOSTNAME.lower()
<                 _recipient = _username + '@' + _hostname
<                 confirm_append_addr = parseaddr(msgobj.get('return-path'))[1]
<                 params = FilterParser.create_sql_params(
<                     recipient=_recipient, username=_username,
<                     hostname=_hostname, sender=confirm_append_addr)
<                 Util.db_insert(Defaults.DB_CONNECTION,
<                                Defaults.DB_PENDING_DELETE_APPEND,
<                                params)
385,386c373
<             if Defaults.PENDING_WHITELIST_APPEND or \
<                (Defaults.DB_PENDING_WHITELIST_APPEND and Defaults.DB_CONNECTION):
---
>             if Defaults.PENDING_WHITELIST_APPEND:
388,389c375
<             if Defaults.PENDING_BLACKLIST_APPEND or \
<                (Defaults.DB_PENDING_BLACKLIST_APPEND and Defaults.DB_CONNECTION):
---
>             if Defaults.PENDING_BLACKLIST_APPEND:
456,465d441
<         if Defaults.DB_PENDING_RELEASE_APPEND and Defaults.DB_CONNECTION:
<             _username = Defaults.USERNAME.lower()
<             _hostname = Defaults.HOSTNAME.lower()
<             _recipient = _username + '@' + _hostname
<             params = FilterParser.create_sql_params(
<                 recipient=_recipient, username=_username,
<                 hostname=_hostname, sender=self.append_address)
<             Util.db_insert(Defaults.DB_CONNECTION,
<                            Defaults.DB_PENDING_RELEASE_APPEND,
<                            params)
490,499d465
<         if Defaults.DB_PENDING_DELETE_APPEND and Defaults.DB_CONNECTION:
<             _username = Defaults.USERNAME.lower()
<             _hostname = Defaults.HOSTNAME.lower()
<             _recipient = _username + '@' + _hostname
<             params = FilterParser.create_sql_params(
<                 recipient=_recipient, username=_username,
<                 hostname=_hostname, sender=self.append_address)
<             Util.db_insert(Defaults.DB_CONNECTION,
<                            Defaults.DB_PENDING_DELETE_APPEND,
<                            params)
504,507c470,471
<         if Defaults.PENDING_WHITELIST_APPEND or \
<            (Defaults.DB_PENDING_WHITELIST_APPEND and Defaults.DB_CONNECTION):
<             if Defaults.PENDING_WHITELIST_APPEND:
<                 Util.append_to_file(self.append_address,
---
>         if Defaults.PENDING_WHITELIST_APPEND:
>             Util.append_to_file(self.append_address,
509,518d472
<             if Defaults.DB_PENDING_WHITELIST_APPEND and Defaults.DB_CONNECTION:
<                 _username = Defaults.USERNAME.lower()
<                 _hostname = Defaults.HOSTNAME.lower()
<                 _recipient = _username + '@' + _hostname
<                 params = FilterParser.create_sql_params(
<                     recipient=_recipient, username=_username,
<                     hostname=_hostname, sender=self.append_address)
<                 Util.db_insert(Defaults.DB_CONNECTION,
<                                Defaults.DB_PENDING_WHITELIST_APPEND,
<                                params)
525,528c479,480
<         if Defaults.PENDING_BLACKLIST_APPEND or \
<            (Defaults.DB_PENDING_BLACKLIST_APPEND and Defaults.DB_CONNECTION):
<             if Defaults.PENDING_BLACKLIST_APPEND:
<                Util.append_to_file(self.append_address,
---
>         if Defaults.PENDING_BLACKLIST_APPEND:
>             Util.append_to_file(self.append_address,
530,539d481
<             if Defaults.DB_PENDING_BLACKLIST_APPEND and Defaults.DB_CONNECTION:
<                 _username = Defaults.USERNAME.lower()
<                 _hostname = Defaults.HOSTNAME.lower()
<                 _recipient = _username + '@' + _hostname
<                 params = FilterParser.create_sql_params(
<                     recipient=_recipient, username=_username,
<                     hostname=_hostname, sender=self.append_address)
<                 Util.db_insert(Defaults.DB_CONNECTION,
<                                Defaults.DB_PENDING_BLACKLIST_APPEND,
<                                params)
_________________________________________________
tmda-workers mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-workers

Reply via email to