[Spambayes-checkins] spambayes/Outlook2000/dialogs ClassifyDialog.py,1.2,1.3 TrainingDialog.py,1.2,1.3

Tim Peters tim_one@users.sourceforge.net
Sat, 19 Oct 2002 22:52:52 -0700


Update of /cvsroot/spambayes/spambayes/Outlook2000/dialogs
In directory usw-pr-cvs1:/tmp/cvs-serv4367/dialogs

Modified Files:
	ClassifyDialog.py TrainingDialog.py 
Log Message:
It turns out that calling mapi.GetFolder() has the atrocious side effect
of changing the working directory to the system MAPI directory on my box,
and that screws up subsequent Python imports to no end.  I'm bracketing
the two GetFolder() calls that kill me all the time by getcwd/chdir
pairs in this checkin, but there are more calls to this routine, and
I don't like this code-duplication approach to the problem (it will
just pop up again the next time someone adds a new GetFolder call).

Mark?  I don't yet have a good enough feel for the Grand Architecture to
know how to do this right.


Index: ClassifyDialog.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/ClassifyDialog.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ClassifyDialog.py	19 Oct 2002 18:14:01 -0000	1.2
--- ClassifyDialog.py	20 Oct 2002 05:52:50 -0000	1.3
***************
*** 1,2 ****
--- 1,4 ----
+ import os
+ 
  from pywin.mfc import dialog
  import win32con
***************
*** 63,66 ****
--- 65,69 ----
      def UpdateStatus(self):
          names = []
+         cwd = os.getcwd()  # mapi.GetFolder() switches to the system MAPI dir
          for eid in self.config.folder_ids:
              try:
***************
*** 70,73 ****
--- 73,77 ----
              names.append(name)
          self.SetDlgItemText(IDC_STATIC_FOLDERS, "; ".join(names))
+         os.chdir(cwd)
  
      def OnBrowse(self, id, code):

Index: TrainingDialog.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/dialogs/TrainingDialog.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TrainingDialog.py	19 Oct 2002 18:14:01 -0000	1.2
--- TrainingDialog.py	20 Oct 2002 05:52:50 -0000	1.3
***************
*** 1,2 ****
--- 1,4 ----
+ import os
+ 
  from pywin.mfc import dialog
  import win32con
***************
*** 63,66 ****
--- 65,69 ----
      def UpdateStatus(self):
          names = []
+         cwd = os.getcwd()  # mapi.GetFolder() switches to the system MAPI dir
          for eid in self.config.ham_folder_ids:
              try:
***************
*** 79,82 ****
--- 82,86 ----
              names.append(name)
          self.SetDlgItemText(IDC_STATIC_SPAM, "; ".join(names))
+         os.chdir(cwd)
  
      def OnBrowse(self, id, code):