CVS: tmda-cgi ChangeLog,1.64,1.65 tmda-cgi.py,1.38,1.39

Gre7g Luterman <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda-cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv29228

Modified Files:
	ChangeLog tmda-cgi.py 
Log Message:
Added a nasty hack to prevent import errors in Python 2.3.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/ChangeLog,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- ChangeLog	15 Nov 2003 17:03:54 -0000	1.64
+++ ChangeLog	16 Nov 2003 17:35:53 -0000	1.65
@@ -1,3 +1,7 @@
+2003-11-16  Gre7g Luterman  <[email protected]>
+
+	* Added a nasty hack to prevent import errors in Python 2.3.
+
 2003-11-15  Gre7g Luterman  <[email protected]>
 
 	* Changed timestamp call in dynamic address tester for compatibility

Index: tmda-cgi.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/tmda-cgi.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- tmda-cgi.py	16 Jun 2003 17:43:18 -0000	1.38
+++ tmda-cgi.py	16 Nov 2003 17:35:53 -0000	1.39
@@ -21,6 +21,24 @@
 
 "Web interface to TMDA tools."
 
+# Python2.3 seems to have a problem when Defaults.py imports various packages
+# from its directory.  This nasty hack intercepts those imports and adds a
+# "from TMDA" to them.
+OldImport = __builtins__.__import__
+def NewImport(name, globals=None, locals=None, fromlist=None):
+  if fromlist == None:
+    if name == "Errors":
+      from TMDA import Errors
+      return Errors
+    if name == "Util":
+      from TMDA import Util
+      return Util
+    if name == "Version":
+      from TMDA import Version
+      return Version
+  return OldImport(name, globals, locals, fromlist)
+__builtins__.__import__ = NewImport
+
 # Prepare the traceback in case of uncaught exception
 import os
 import sys
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.