I've attached a patch (against today's release-1-1 branch in CVS) that does two things:

1)

If variables named in _path_vars aren't defined at all, Defaults.py would throw an exception. This is fixed by the following snippet:

-    if isinstance(_defaults[var], str):
+    if _defaults.has_key(var) and isinstance(_defaults[var], str):

In my case, SENDMAIL_PROGRAM wasn't defined since my outbound mail is sent via SMTP.

2)

I'm only using TMDA-1.1 on a test user at present, so I have 1.0 and 1.1 installed. I (may) need two different configuration files for these versions. This patch takes the values of GLOBAL_TMDARC and TMDARC and attempts to look for versions suffixed with the TMDA branch number (e.g. "1.1") or falls back to the existing name if that isn't found.

That way, I can have:

/etc/tmdarc-1.1
/etc/tmdarc      (for 1.0 - still used for 1.1 if above not present)

Also, if TMDARC is set during parsing of GLOBAL_TMDARC, the TMDARC value is not always over-written by reading from the environment, hence allowing GLOBAL_TMDARC to specify the name of TMDARC.

--
Stephen Warren, Software Engineer, Parama Networks, San Jose, CA
[EMAIL PROTECTED]                  http://www.wwwdotorg.org/

? supervise
Index: TMDA/Defaults.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Defaults.py,v
retrieving revision 1.201
diff -u -r1.201 Defaults.py
--- TMDA/Defaults.py    21 Feb 2004 01:09:20 -0000      1.201
+++ TMDA/Defaults.py    22 Feb 2004 06:28:58 -0000
@@ -39,6 +39,7 @@
 import sys
 
 import Errors
+import Version
 
 
 ##############################
@@ -68,12 +69,19 @@
 # If the file /etc/tmdarc exists, read it before ~/.tmda/config.
 # Make site-wide configuration changes to this file.
 GLOBAL_TMDARC = '/etc/tmdarc'
-if os.path.exists(GLOBAL_TMDARC):
+GLOBAL_TMDARC_V = GLOBAL_TMDARC + "-" + Version.TMDA_MAJMIN
+rcs = [GLOBAL_TMDARC_V, GLOBAL_TMDARC]
+for rc in rcs:
+    if not os.path.exists(rc):
+        continue
+    GLOBAL_TMDARC = rc
     execfile(GLOBAL_TMDARC)
-        
+    break
+ 
 # Look for the user-config-file in the environment first then default
 # to ~/.tmda/config
-TMDARC = os.environ.get('TMDARC')
+if not vars().has_key('TMDARC'):
+    TMDARC = os.environ.get('TMDARC')
 if not TMDARC:
     TMDARC = os.path.expanduser('~/.tmda/config')
 
@@ -86,7 +94,12 @@
     CONFIG_EXEC = 1
 
 # Read-in the user's configuration file.
-if os.path.exists(TMDARC):
+TMDARC_V = TMDARC + "-" + Version.TMDA_MAJMIN
+rcs = [TMDARC_V, TMDARC]
+for rc in rcs:
+    if not os.path.exists(rc):
+        continue
+    TMDARC = rc
     if CONFIG_EXEC:
         execfile(TMDARC)
     else:
@@ -103,10 +116,10 @@
                 exec('%s = %s' % (option, value))
             else:
                 exec('%s = "%s"' % (option, value))
+    break
 
 
 import Util
-import Version
 
 TMDA_HOMEPAGE = "(http://tmda.net/)"
 TMDA_VERSION = Version.TMDA
@@ -1567,7 +1580,7 @@
 
 _defaults = globals()
 for var in _path_vars:
-    if isinstance(_defaults[var], str):
+    if _defaults.has_key(var) and isinstance(_defaults[var], str):
         _defaults[var] = os.path.expanduser(_defaults[var])
 
 
Index: TMDA/Version.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/Version.py,v
retrieving revision 1.124
diff -u -r1.124 Version.py
--- TMDA/Version.py     12 Feb 2004 20:29:46 -0000      1.124
+++ TMDA/Version.py     22 Feb 2004 06:28:58 -0000
@@ -26,7 +26,13 @@
 
 
 # TMDA version
-TMDA = "1.1.2+"
+MAJOR = 1
+MINOR = 1
+LEVEL = 2
+EXTRA = "+"
+
+TMDA_MAJMIN = str(MAJOR) + "." + str(MINOR)
+TMDA = TMDA_MAJMIN + "." + str(LEVEL) + str(EXTRA)
 
 # TMDA version codename
 CODENAME = "Dailuaine"
_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to