Index: trunk/ippToPsps/jython/detectionbatch.py
===================================================================
--- trunk/ippToPsps/jython/detectionbatch.py	(revision 31351)
+++ trunk/ippToPsps/jython/detectionbatch.py	(revision 31357)
@@ -58,4 +58,11 @@
 
        self.totalNumPhotoRef = 0
+
+       # get filterID using init table
+       self.filter = self.header['FILTERID'][0:1]
+
+       # insert what we know about this stack batch into the stack table
+       self.ippToPspsDb.insertDetectionMeta(self.batchID, self.expID, self.filter)
+
 
     '''
@@ -490,7 +497,4 @@
     def populatePspsTables(self):
 
-        # get filterID using init table
-        self.filter = self.header['FILTERID'][0:1]
-
         self.populateFrameMeta()
      
@@ -592,4 +596,10 @@
         self.scratchDb.stmt.execute(sql)
 
+    '''
+    Checks whether this batch has already been processed and published
+    '''
+    def alreadyProcessed(self):
+
+        return self.ippToPspsDb.alreadyProcessed("detection", "exp_id", self.expID)
 
 
@@ -621,13 +631,16 @@
     #file = "detdemo.fits" 
     detectionBatch = DetectionBatch(logger, camID, file, True)
-    detectionBatch.createEmptyPspsTables()
-    detectionBatch.importIppTables("XY33\.psf")
-    if detectionBatch.populatePspsTables():
-        detectionBatch.exportPspsTablesToFits("([a-zA-Z]+)")
-        detectionBatch.writeBatchManifest()
-        detectionBatch.reportNullsInAllPspsTables(False)
-        #detectionBatch.createTarball()
-        #detectionBatch.publishToDatastore()
-
+
+    if not detectionBatch.alreadyProcessed():
+
+        detectionBatch.createEmptyPspsTables()
+        detectionBatch.importIppTables("XY33\.psf")
+        if detectionBatch.populatePspsTables():
+            detectionBatch.exportPspsTablesToFits("([a-zA-Z]+)")
+            detectionBatch.writeBatchManifest()
+            detectionBatch.reportNullsInAllPspsTables(False)
+            #detectionBatch.createTarball()
+            #detectionBatch.publishToDatastore()
+    
     i = i+1
     if i > 0: break
