Index: trunk/ippToPsps/jython/loader.py
===================================================================
--- trunk/ippToPsps/jython/loader.py	(revision 33553)
+++ trunk/ippToPsps/jython/loader.py	(revision 33554)
@@ -50,8 +50,8 @@
             self.logger.errorPair("Cannot connect to a", "scratch database")
             exitProgram("no available scratch database")
-        
-        # now pass scratch Db to dvo object
-        self.dvo = Dvo(self.logger, self.config)
-        self.dvo.setScratchDb(self.scratchDb.dbName)
+       
+        # create Dvo and Datastore objects
+        self.dvo = Dvo(self.logger, self.config, self.scratchDb.dbName)
+        self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
 
         # if an IN batch is requested, create and quit
@@ -79,15 +79,29 @@
 
     '''
-    Overrides base-class version
+    Overrides base-class version so we can ensure our scratch Db is using the right DVO Db
     '''
     def refreshConfig(self):
 
         ret = super(Loader, self).refreshConfig()
-        
-        try: self.dvo.setScratchDb(self.scratchDb.dbName)
-        except: pass
-        self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
+        try: dvo
+        except: return ret
+
+        dvo.checkDvoLocation()
 
         return ret
+
+    '''
+    Overrides base_class version so we can break out of processing loops if the config changes
+    '''
+    def checkClientStatus(self):
+
+        oldConfigName = self.config.name
+        super(Loader, self).checkClientStatus()
+        if oldConfigName != self.config.name:
+            self.logger.infoPair("Config changed",  "from '" + oldConfigName + "' to '" + self.config.name + "'")
+            self.config.printAll()
+            return False
+
+        return True
 
     '''
@@ -99,4 +113,5 @@
         while True:
 
+            abort = False
             for batchType in self.config.batchTypes:
 
@@ -112,5 +127,7 @@
                 for boxId in boxIds:
           
-                    self.checkClientStatus()
+                    if not self.checkClientStatus():
+                        abort = True
+                        break
     
                     # get box info. if boxes have changed, break and start again
@@ -151,8 +168,10 @@
                 
                     self.logger.infoBool("Using pre-ingested DVO data?", useFullTables)
-                    self.processTheseItems(batchType, ids, useFullTables)
-
-            self.checkClientStatus()
-            if numAttempts > 1 and not self.waitForPollTime(): break
+                    if not self.processTheseItems(batchType, ids, useFullTables):
+                        abort = True
+                        break
+
+            if abort or not self.checkClientStatus(): abort = True
+            elif numAttempts > 1 and not self.waitForPollTime():  break
 
         
@@ -200,6 +219,5 @@
             batch.run()
     
-            # check that we should continue
-            self.checkClientStatus()
+            if not self.checkClientStatus(): return False
     
             self.ippToPspsDb.lockBatchTable()
@@ -212,4 +230,6 @@
         self.ippToPspsDb.unlockTables()
         self.logger.infoPair("Unattempted batches", "%d" % unattemptedCount)
+
+        return True
     
     '''
