SF.net SVN: tmda: [2033] trunk/tmda

[email protected] Fri, 22 Sep 2006 16:30:54 -0700
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Revision: 2033
          http://svn.sourceforge.net/tmda/?rev=2033&view=rev
Author:   jasonrm
Date:     2006-09-22 16:30:51 -0700 (Fri, 22 Sep 2006)

Log Message:
-----------
playing around with some reorganization ideas.

Modified Paths:
--------------
    trunk/tmda/bin/ChangeLog
    trunk/tmda/bin/tmda-rfilter

Added Paths:
-----------
    trunk/tmda/TMDA/Queue/
    trunk/tmda/TMDA/Queue/ChangeLog
    trunk/tmda/TMDA/Queue/Util.py
    trunk/tmda/TMDA/Queue/__init__.py


Property changes on: trunk/tmda/TMDA/Queue
___________________________________________________________________
Name: svn:ignore
   + *.pyc


Added: trunk/tmda/TMDA/Queue/ChangeLog
===================================================================
--- trunk/tmda/TMDA/Queue/ChangeLog	                        (rev 0)
+++ trunk/tmda/TMDA/Queue/ChangeLog	2006-09-22 23:30:51 UTC (rev 2033)
@@ -0,0 +1,5 @@
+2006-09-22  Jason R. Mastaler  <[email protected]>
+
+	* Util.py: new file.
+	
+

Added: trunk/tmda/TMDA/Queue/Util.py
===================================================================
--- trunk/tmda/TMDA/Queue/Util.py	                        (rev 0)
+++ trunk/tmda/TMDA/Queue/Util.py	2006-09-22 23:30:51 UTC (rev 2033)
@@ -0,0 +1,57 @@
+# -*- python -*-
+#
+# Copyright (C) 2001,2002,2003,2004,2005,2006 Jason R. Mastaler <[email protected]>
+#
+# This file is part of TMDA.
+#
+# TMDA is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.  A copy of this license should
+# be included in the file COPYING.
+#
+# TMDA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with TMDA; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""General purpose (Pending Queue related) functions."""
+
+
+import os
+
+from TMDA import Errors
+from TMDA import Defaults
+from TMDA.Util import msg_as_string, writefile
+
+
+def create_pending_dir(dirpath=None):
+    """ """
+    if not dirpath:
+	dirpath = Defaults.PENDING_DIR
+    if not os.path.exists(dirpath):
+	os.makedirs(dirpath, 0700)
+    
+
+def create_pending_msg(timestamp, pid, msg):
+    """ """
+    fname = "%s.%s.msg" % (timestamp, pid)
+    # Create ~/.tmda/ and friends if necessary.
+    create_pending_dir(Defaults.PENDING_DIR)
+    # Write ~/.tmda/pending/TIMESTAMP.PID.msg
+    fcontents = msg_as_string(msg)
+    fpath = os.path.join(Defaults.PENDING_DIR, fname)
+    writefile(fcontents, fpath)
+    return fname
+
+
+def maildirmake(dirpath):
+    """ """
+    os.makedirs(os.path.join(dirpath, 'cur'), 0700)
+    os.mkdir(os.path.join(dirpath, 'new'), 0700)
+    os.mkdir(os.path.join(dirpath, 'tmp'), 0700)
+    

Added: trunk/tmda/TMDA/Queue/__init__.py
===================================================================
--- trunk/tmda/TMDA/Queue/__init__.py	                        (rev 0)
+++ trunk/tmda/TMDA/Queue/__init__.py	2006-09-22 23:30:51 UTC (rev 2033)
@@ -0,0 +1,20 @@
+# -*- python -*-
+#
+# Copyright (C) 2001,2002,2003,2004,2005,2006 Jason R. Mastaler <[email protected]>
+#
+# This file is part of TMDA.
+#
+# TMDA is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.  A copy of this license should
+# be included in the file COPYING.
+#
+# TMDA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with TMDA; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Modified: trunk/tmda/bin/ChangeLog
===================================================================
--- trunk/tmda/bin/ChangeLog	2006-09-22 17:39:22 UTC (rev 2032)
+++ trunk/tmda/bin/ChangeLog	2006-09-22 23:30:51 UTC (rev 2033)
@@ -1,3 +1,7 @@
+2006-09-22  Jason R. Mastaler  <[email protected]>
+
+	* tmda-rfilter (create_pending_msg): Move to TMDA.Queue.Util.
+	
 2004-03-25  Jason R. Mastaler  <[email protected]>
 
 	* tmda-ofmipd: Add -P / --pure-proxy.

Modified: trunk/tmda/bin/tmda-rfilter
===================================================================
--- trunk/tmda/bin/tmda-rfilter	2006-09-22 17:39:22 UTC (rev 2032)
+++ trunk/tmda/bin/tmda-rfilter	2006-09-22 23:30:51 UTC (rev 2033)
@@ -179,8 +179,8 @@
 from TMDA import FilterParser
 from TMDA import MTA
 from TMDA import Util
+from TMDA.Queue.Util import create_pending_msg
 
-
 from cStringIO import StringIO
 from email.Utils import parseaddr, getaddresses
 import email
@@ -640,22 +640,7 @@
                           'bounce_fail_keyword.txt')
 
 
-def create_pending_msg(timestamp, pid):
-    pending_message = "%s.%s.msg" % (timestamp, pid)
-    # Create ~/.tmda/ and friends if necessary.
-    if not os.path.exists(pendingdir):
-        os.makedirs(pendingdir, 0700) # stores the unconfirmed messages
-    # X-TMDA-Recipient is used by release_pending().
-    del msgin['X-TMDA-Recipient']
-    msgin['X-TMDA-Recipient'] = recipient_address
-    # Write ~/.tmda/pending/TIMESTAMP.PID.msg
-    pending_contents = Util.msg_as_string(msgin)
-    fn = os.path.join(pendingdir, pending_message)
-    Util.writefile(pending_contents, fn)
-    del msgin['X-TMDA-Recipient']
-    return pending_message
 
-
 def bouncegen(mode, template=None):
     """Bounce a message back to sender."""
     # Stop right away if --discard was specified.
@@ -721,9 +706,17 @@
                                                   Cookie.make_confirm_cookie(timestamp,
                                                                              pid,
                                                                              'accept'))
-        pending_message = create_pending_msg(timestamp, pid)
+	# X-TMDA-Recipient is used by release_pending()
+	del msgin['X-TMDA-Recipient']
+        msgin['X-TMDA-Recipient'] = recipient_address
+        pending_message = create_pending_msg(timestamp, pid, msgin)
+	del msgin['X-TMDA-Recipient']
+    
     elif mode == 'hold':
-        pending_message = create_pending_msg(str('%d' % now), Defaults.PID)
+	del msgin['X-TMDA-Recipient']
+        msgin['X-TMDA-Recipient'] = recipient_address
+        pending_message = create_pending_msg(str('%d' % now), Defaults.PID, msgin)
+	del msgin['X-TMDA-Recipient']
         # Don't send anything for silently held messages
         if Defaults.CONFIRM_CC:
             send_cc(Defaults.CONFIRM_CC)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.