CVS: tmda-cgi CgiUtil.py,1.18,1.19 ChangeLog,1.29,1.30 Install.py,1.10,1.11 Session.py,1.32,1.33 TODO,1.16,1.17 UPGRADE,1.14,1.15 Unicode.py,1.2,1.3 tmda-cgi.py,1.34,1.35

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-serv11950

Modified Files:
	CgiUtil.py ChangeLog Install.py Session.py TODO UPGRADE 
	Unicode.py tmda-cgi.py 
Log Message:
Removed Python 2.2 dependency.

Removed permissions.ini from install and added anomalies which will let the
sysadmin configure more stuff.

Extended iso-8859-1 codec so it works for us-ascii character set.

Minor tweak to the short header format in the e-mail viewer.


Index: CgiUtil.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/CgiUtil.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- CgiUtil.py	13 May 2003 21:29:08 -0000	1.18
+++ CgiUtil.py	21 May 2003 05:09:30 -0000	1.19
@@ -51,7 +51,7 @@
 
 def Size(MsgObj = None, MsgSize = 0):
   if MsgObj:
-    MsgSize = os.stat(MsgObj.msgfile).st_size
+    MsgSize = os.stat(MsgObj.msgfile)[6]
   if MsgSize > 512:
     if MsgSize > 5120:
       if MsgSize > 524288:

Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/ChangeLog,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ChangeLog	14 May 2003 16:19:55 -0000	1.29
+++ ChangeLog	21 May 2003 05:09:31 -0000	1.30
@@ -1,3 +1,14 @@
+2003-05-20  Gre7g Luterman  <[email protected]>
+
+	* Removed Python 2.2 dependency.
+
+	* Removed permissions.ini from install and added anomalies which will
+	  let the sysadmin configure more stuff.
+
+	* Extended iso-8859-1 codec so it works for us-ascii character set.
+
+	* Minor tweak to the short header format in the e-mail viewer.
+
 2003-05-14  Gre7g Luterman  <[email protected]>
 
 	* Changed the configure program so users can do the "make install" as

Index: Install.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/Install.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Install.py	14 May 2003 05:58:05 -0000	1.10
+++ Install.py	21 May 2003 05:09:31 -0000	1.11
@@ -34,8 +34,6 @@
 from TMDA import Errors
 from TMDA import Util
 
-PermSearch = re.compile("^([^#\s]\S*)\s+(\d+)")
-
 def KeyGen():
   # Generate a random key
   RandomDev = "/dev/urandom"
@@ -61,7 +59,7 @@
   Files = os.listdir(AbsPath)
   RetVal = []
   for File in Files:
-    if (File != "CVS") and (File != "permissions.ini"):
+    if (File != "CVS") and (File != "anomalies"):
       FilePath = os.path.join(Path, File)
       AbsFilePath = os.path.join(AbsPath, File)
       L = len(RetVal)
@@ -175,12 +173,14 @@
   CgiUtil.TermError("Install aborted.", ErrStr, "install TMDA",
     "", "Check file permissions in home directory.")
 
-def ListDiff(a, b):
+def ListDiff(a, b, Dict = None):
   "Take all items in b out of a."
   try:
     i = 0
     while 1:
-      if (a[i] % Dict) in b:
+      Item = a[i]
+      if Dict: Item = Item % Dict
+      if Item in b:
         del a[i]
       else:
         i += 1
@@ -224,37 +224,69 @@
       # Install failed, revert!
       Revert(Copied, Backup, "Expanding %%'s in: %s<br>%s" % (Filename,
         ErrStr))
-  ListDiff(FilesToCopy, Failed)
-
-def SetPerms(SrcDir, Files, Backup):
-  "Set permissions as listed in permissions.ini"
+  ListDiff(FilesToCopy, Failed, Dict)
 
-  # Read in permission instructions
-  try:
-    F = open(os.path.join("skel", SrcDir, "permissions.ini"))
-    Lines = F.readlines()
-    F.close()
-  except IOError:
-    return
+def SetPerms(Anomalies, Files, Backup):
+  "Set permissions as listed in anomalies"
 
   # Parse and execute instructions
   try:
-    for Line in Lines:
-      Match = PermSearch.search(Line)
-      if Match:
-        os.chmod(os.path.join(os.environ["HOME"], Match.group(1)),
-          eval("0" + Match.group(2)))
+    for File in Anomalies.keys():
+      os.chmod(os.path.join(os.environ["HOME"], File % Dict), Anomalies[File])
   except OSError, (ErrStr):
     Revert(Files, Backup, "Setting permission %s on: %s<br>%s" % \
-      (Match.group(2), Match.group(1), ErrStr))
+      (Anomalies[File], File % Dict, ErrStr))
+
+def GetAnomalies(Dir):
+  "Find any anomaly instructions."
+  RetVal = \
+  {
+    "PERMISSIONS": {}, "VIRTUAL_TEST": "", "REAL_ONLY": [], "VIRTUAL_ONLY": []
+  }
+  try:
+    execfile(os.path.join("skel", Dir, "anomalies"), RetVal)
+  except IOError:
+    pass
+  return RetVal
+
+def ReimportDefaults(Files, Backup):
+  """During an install/restore, we need to reload Defaults.  This is easy to do
+under Python 2.2, but for some reason Python 2.1 will return a generic 
+Exception. To circumvent this problem, we use execfile and let Defaults be a 
+dictionary instead of a module to access the contents.  Ugly, but effective."""
+  try:
+    CWD = os.getcwd()
+    os.chdir(os.path.join(os.environ["TMDA_BASE_DIR"], "TMDA"))
+    Defaults = {}
+    execfile("Defaults.py", Defaults)
+    os.chdir(CWD)
+
+    # Provide access to Defaults so Session.Save() will work
+    import Session
+    Session.Defaults = Defaults
+
+  except Errors.ConfigError, ErrStr:
+    os.chdir(CWD)
+    Revert(Files, Backup, "Re-importing Defaults<br>%s" % ErrStr)
+
+  return Defaults
 
 def Install():
   "Do the actual installation."
 
+  # Find any anomaly instructions
+  Anomalies = GetAnomalies("install")
+
   # What files do we need to install?
   InstallDir = os.path.join(os.getcwd(), "skel", "install")
   FilesToInstall = FindFiles("", InstallDir)
 
+  # Are we supposed to ignore any of those?
+  if re.search(Anomalies["VIRTUAL_TEST"], PVars["HOME"]):
+    ListDiff(FilesToInstall, Anomalies["REAL_ONLY"])
+  else:
+    ListDiff(FilesToInstall, Anomalies["VIRTUAL_ONLY"])
+
   # What files will that clobber?
   FilesClobbered = FindExisting(FilesToInstall, os.environ["HOME"])
 
@@ -275,7 +307,7 @@
     FilesToInstall[i] = FilesToInstall[i] % Dict
 
   # Set file permissions
-  SetPerms("install", FilesToInstall, Backup)
+  SetPerms(Anomalies["PERMISSIONS"], FilesToInstall, Backup)
 
   # Unlink any restore file
   Archive = os.path.join(os.environ["HOME"],
@@ -286,22 +318,8 @@
     except OSError:
       pass
 
-  # At this point, we need to reload Defaults.  This is easy to do under
-  # Python 2.2, but for some reason Python 2.1 will return an ImportError.
-  # To circumvent this problem, we use execfile and let Defaults be a
-  # dictionary instead of a module to access the contents.  Ugly, but
-  # effective.
-
   # Try to import Defaults again.
-  try:
-    CWD = os.getcwd()
-    os.chdir(os.path.join(os.environ["TMDA_BASE_DIR"], "TMDA"))
-    Defaults = {}
-    execfile("Defaults.py", Defaults)
-    os.chdir(CWD)
-  except Errors.ConfigError:
-    os.chdir(CWD)
-    Revert(FilesToInstall, Backup, "Re-importing Defaults<br>%s" % ErrStr)
+  Defaults = ReimportDefaults(FilesToInstall, Backup)
 
   # Prepare template
   T = Template.Template("installed.html")
@@ -330,6 +348,9 @@
 def Uninstall():
   "Do the actual uninstallation."
 
+  # Find any anomaly instructions
+  Anomalies = GetAnomalies("uninstall")
+
   # What files do we need to uninstall?
   InstallDir = os.path.join(os.getcwd(), "skel", "install")
   Files = FindFiles("", InstallDir)
@@ -355,13 +376,22 @@
   UninstallDir = os.path.join(os.getcwd(), "skel", "uninstall")
   UninstallFiles = FindFiles("", UninstallDir)
 
+  # Are we supposed to ignore any of those?
+  if re.search(Anomalies["VIRTUAL_TEST"], PVars["HOME"]):
+    ListDiff(UninstallFiles, Anomalies["REAL_ONLY"])
+  else:
+    ListDiff(UninstallFiles, Anomalies["VIRTUAL_ONLY"])
+
   # Don't clobber anything.
   FilesClobbered = FindExisting(UninstallFiles, os.environ["HOME"])
-  ListDiff(UninstallFiles, FilesClobbered)
+  ListDiff(UninstallFiles, FilesClobbered, Dict)
 
   # Copy files from skeleton
   CopyFiles(UninstallFiles, UninstallDir, Backup)
 
+  # Set file permissions
+  SetPerms(Anomalies["PERMISSIONS"], UninstallFiles, Backup)
+
   # Unlink any empty directories used
   Dirs = {}
   for File in RemoveFiles:
@@ -392,7 +422,7 @@
       os.unlink(Archive)
     except OSError:
       pass
-    ListDiff(UninstallFiles, RestoredFiles)
+    ListDiff(UninstallFiles, RestoredFiles, Dict)
   else:
     Archive = None
 
@@ -505,14 +535,11 @@
     pass
 
   # Try to import Defaults again.
-  try:
-    from TMDA import Defaults
-  except Errors.ConfigError:
-    Revert(FilesToInstall, Backup, "Re-importing Defaults<br>%s" % ErrStr)
+  Defaults = ReimportDefaults(FilesToInstall, Backup)
 
   # Prepare template
   T = Template.Template("installed.html")
-  T["EMail"] = "%s@%s" % (Defaults.USERNAME, Defaults.HOSTNAME)
+  T["EMail"] = "%s@%s" % (Defaults["USERNAME"], Defaults["HOSTNAME"])
   Row = T["Row"]
   if len(FilesClobbered):
     # List files clobbered

Index: Session.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/Session.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Session.py	14 May 2003 05:58:05 -0000	1.32
+++ Session.py	21 May 2003 05:09:31 -0000	1.33
@@ -164,10 +164,16 @@
 
     CWD = os.getcwd()
     if self.RealUser:
-      from TMDA import Defaults
-      os.chdir(os.path.split(Defaults.TMDARC)[0])
-      Filename = Defaults.CGI_SETTINGS
-      Data     = self.PVars
+      # Not sure why I have to refer to Defaults via globals(), but it works
+      if globals().has_key("Defaults") and \
+        (type(globals()["Defaults"]) == DictType):
+        os.chdir(os.path.split(globals()["Defaults"]["TMDARC"])[0])
+        Filename = globals()["Defaults"]["CGI_SETTINGS"]
+      else:
+        from TMDA import Defaults
+        os.chdir(os.path.split(Defaults.TMDARC)[0])
+        Filename = Defaults.CGI_SETTINGS
+      Data = self.PVars
     else:
       self.__suid__("web")
       Filename = os.environ["TMDA_SESSION_PREFIX"] + self.SID
@@ -469,7 +475,10 @@
 
   def __delitem__(self, a):
     if type(a) in [StringType, UnicodeType]:
-      del self.PVars[a]
+      if self.PVars.has_key(a):
+        del self.PVars[a]
+      else:
+        del self.Vars[a]
     else:
       ID = ":".join(a)
       if self.PVars.has_key(ID):
@@ -479,7 +488,10 @@
 
   def __getitem__(self, a):
     if type(a) in [StringType, UnicodeType]:
-      return self.PVars[a]
+      if self.PVars.has_key(a):
+        return self.PVars[a]
+      else:
+        return self.Vars[a]
     else:
       ID = ":".join(a)
       if self.PVars.has_key(ID):
@@ -495,7 +507,7 @@
 
   def has_key(self, a):
     if type(a) in [StringType, UnicodeType]:
-      return self.PVars.has_key(a)
+      return self.PVars.has_key(a) or self.Vars.has_key(a)
     else:
       return self.PVars.has_key(":".join(a)) or \
         self.ThemeVars.has_option(a[0], a[1])

Index: TODO
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/TODO,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TODO	16 May 2003 19:59:45 -0000	1.16
+++ TODO	21 May 2003 05:09:31 -0000	1.17
@@ -1,15 +1,17 @@
 Things left to do:
 ==================
 
+    * Custom Filter -- action for pending emails (Requested by Lloyd Zusman)
+
+    * Install -- catch failure if bad %(__)s in skel file
+
     * FAQ -- should this be made a CGI?  Add help on adding whitelist &
              blacklist options.
 
     * Filter Viewer -- graphic view of your filters
 
+    * Search -- for pending list and/or lists and filters
+
     * Tutorial -- finish section on mailing lists
 
     * URL Confirmation -- virtual user support untested
-
-    * Search functionality for pending list and/or lists and filters
-
-    * "Custom filter" action for pending emails (Requested by Lloyd Zusman)

Index: UPGRADE
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/UPGRADE,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- UPGRADE	20 May 2003 22:31:31 -0000	1.14
+++ UPGRADE	21 May 2003 05:09:31 -0000	1.15
@@ -28,6 +28,11 @@
   NOTE: Later versions of tmda-cgi will NOT support old-style confirm-accept
         URLs (and will require TMDA 0.78 or later).
 
+* Removed skel/install/permissions.ini and added anomalies files to install
+  and uninstall which will let the sysadmin configure more stuff.  If you have
+  made a special skel directory for your system, please consult the docs on
+  "anomalies" so you can adapt it for your needs.
+
 ======================================================================
 
 If you are upgrading from a release of tmda-cgi < 0.08:

Index: Unicode.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/Unicode.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Unicode.py	14 May 2003 05:58:05 -0000	1.2
+++ Unicode.py	21 May 2003 05:09:31 -0000	1.3
@@ -73,11 +73,11 @@
   CharSet = CS.input_charset
 
   # Find appropriate decoder
-  if CharSet == "iso-8859-1":
+  if CharSet in ("iso-8859-1", "us-ascii"):
     Decoder = Iso8859
   else:
     try:
-      Decoder = codecs.getdecoder(CharSet)
+      Decoder = codecs.lookup(CharSet)[1]
     except LookupError:
       try:
         # Is it GB2312?

Index: tmda-cgi.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/tmda-cgi.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- tmda-cgi.py	13 May 2003 21:29:08 -0000	1.34
+++ tmda-cgi.py	21 May 2003 05:09:31 -0000	1.35
@@ -183,3 +183,4 @@
   CgiUtil.TermError("No command instruction.", "Program bug.",
     "interpret command", "", "Please contact the programmers and let them "
     "know what you did to reach this message.")
+

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
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.