Index: trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- trunk/ippToPsps/jython/ipptopspsdb.py	(revision 34661)
+++ trunk/ippToPsps/jython/ipptopspsdb.py	(revision 35097)
@@ -17,6 +17,12 @@
     Constructor
     '''
-    def __init__(self, logger, config):
-        super(IppToPspsDb, self).__init__(logger, config, "ipptopspsdatabase")
+    def __init__(self, logger, config, skychunk):
+        if (config.test): 
+            dbType = "ipptopspsdatabase_test"
+        else:
+            dbType = "ipptopspsdatabase"
+        super(IppToPspsDb, self).__init__(logger, config, dbType)
+
+        self.skychunk = skychunk
 
         self.MAX_FAILS = 5
@@ -29,7 +35,7 @@
         sql = "SELECT DISTINCT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
                AND batch_type = '" + batchType + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND merged = 1 \
                AND " + column + " = 0"
@@ -54,7 +60,7 @@
         sql = "SELECT DISTINCT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
                AND batch_type = '" + batchType + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND purged = 1 \
                AND " + column + " = 0"
@@ -80,7 +86,7 @@
         sql = "SELECT DISTINCT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
                AND batch_type = '" + batchType + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND (loaded_to_ODM = -1 OR merge_worthy = 1) \
                AND " + column + " = 0"
@@ -148,7 +154,7 @@
         sql = "SELECT DISTINCT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
                AND batch_type = '" + batchType + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND processed = 1\
                AND loaded_to_datastore != 1 \
@@ -177,6 +183,6 @@
         sql = "SELECT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND loaded_to_datastore = 1 \
                AND batch_type = '" + batchType + "' \
@@ -206,6 +212,6 @@
         sql = "SELECT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND loaded_to_datastore = 1 \
                AND batch_type = '" + batchType + "' \
@@ -235,6 +241,6 @@
         sql = "SELECT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND merge_worthy = 1 \
                AND batch_type = '" + batchType + "' \
@@ -262,6 +268,6 @@
         sql = "SELECT DISTINCT batch_id \
                FROM batch \
-               WHERE timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               WHERE timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND " + column + " = " + str(value)
 
@@ -288,6 +294,6 @@
                FROM batch \
                WHERE batch_type = '" + batchType + "' \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND processed = 1 \
                AND loaded_to_datastore = 1 \
@@ -315,6 +321,6 @@
                FROM batch \
                WHERE batch_type = '" + batchType + "' \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND " + column + " = " + str(value)
 
@@ -387,6 +393,6 @@
                WHERE batch_type = '" + batchType + "' \
                AND processed = 1 \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND timestamp BETWEEN now() - INTERVAL " + interval + " AND now()"
 
@@ -412,6 +418,6 @@
                WHERE batch_type = '" + batchType + "' \
                AND loaded_to_datastore = 1 \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                ORDER BY timestamp DESC LIMIT 1"
 
@@ -511,5 +517,5 @@
                WHERE stage_id = " + str(stage_id) + " \
                AND batch_type = '" + batchType + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND batch_type != 'IN' \
                AND timestamp BETWEEN now() - INTERVAL 12 HOUR AND now()"
@@ -554,6 +560,6 @@
                WHERE stage_id = " + str(stage_id) + " \
                AND batch_type = '" + batchType + "' \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND batch_type != 'IN' \
                AND processed = 1"
@@ -579,6 +585,6 @@
                WHERE stage_id = " + str(stage_id) + " \
                AND batch_type = '" + batchType + "' \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND processed = -1"
 
@@ -602,6 +608,6 @@
                FROM batch \
                WHERE batch_type = '" + batchType + "' \
-               AND timestamp > '" + self.config.epoch + "' \
-               AND dvo_db = '" + self.config.dvoLabel + "' \
+               AND timestamp > '" + self.skychunk.epoch + "' \
+               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
                AND processed = -1 \
                GROUP BY stage_id HAVING numoccur >= " + str(self.MAX_FAILS)
@@ -634,5 +640,5 @@
         batchID = -1;
 
-        if self.config.force or \
+        if self.skychunk.force or \
             (not self.alreadyProcessed(batchType, stageID) \
             and not self.processingNow(batchType, stageID) \
@@ -650,7 +656,7 @@
                        '" + batchType + "', \
                        " + str(stageID) + ", \
-                       '" + self.config.survey + "', \
-                       '" + self.config.dvoLabel + "', \
-                       '" + self.config.datastoreProduct + "' \
+                       '" + self.skychunk.survey + "', \
+                       '" + self.skychunk.dvoLabel + "', \
+                       '" + self.skychunk.datastoreProduct + "' \
                        )"
             self.logger.infoPair("heather:","sql")
@@ -749,18 +755,19 @@
 
     '''
-    Sets the config field for this client
-    '''
-    def setConfigForThisClient(self, config, host, pid):
-
-        self.execute("UPDATE clients SET config = '" + config + "' \
+    Sets the skychunk field for this client
+    '''
+    def setSkychunkForThisClient(self, skychunk, host, pid):
+
+        self.execute("UPDATE clients SET skychunk = '" + skychunk + "' \
                 WHERE host = '" + host + "' \
                 AND pid = " + str(pid))
-    '''
-    Sets the config field for a set of loader clients
-    '''
-    def setConfigForLoaders(self, config, ids):
+
+    '''
+    Sets the skychunk field for a set of loader clients
+    '''
+    def setSkychunkForLoaders(self, skychunk, ids):
 
         for id in ids:
-            self.execute("UPDATE clients SET config = '" + config + "' \
+            self.execute("UPDATE clients SET skychunk = '" + skychunk + "' \
                     WHERE type = 'loader.py' \
                     AND id = " + str(id))
@@ -796,5 +803,5 @@
     '''
     def insertClient(self, type, host, pid):
-        self.execute("INSERT INTO clients (timestamp, type, host, pid, config) VALUES (now(), '" + type + "', '" + host + "', " + str(pid) + ", '" + self.config.name + "')")
+        self.execute("INSERT INTO clients (timestamp, type, host, pid, skychunk) VALUES (now(), '" + type + "', '" + host + "', " + str(pid) + ", '" + self.skychunk.name + "')")
 
     '''
@@ -831,5 +838,5 @@
         try:
             rs = self.executeQuery(sql)
-            rs.first()
+            if rs.first() is False:  return False
             if rs.getInt(1) == 1: return True
             else: return False
@@ -840,41 +847,41 @@
 
     '''
-    Returns a list of available configs
-    '''
-    def getActiveConfigList(self):
+    Returns a list of available skychunks
+    '''
+    def getActiveSkychunkList(self):
         
-        sql = "SELECT DISTINCT name FROM config WHERE active = 1 ORDER BY name"
-
-        configs = []
-        try:
-            rs = self.executeQuery(sql)
-            while (rs.next()): configs.append(rs.getString(1))
-        except:
-            self.logger.errorPair("Can't get config names", sql)
+        sql = "SELECT DISTINCT name FROM skychunk WHERE active = 1 ORDER BY name"
+
+        skychunks = []
+        try:
+            rs = self.executeQuery(sql)
+            while (rs.next()): skychunks.append(rs.getString(1))
+        except:
+            self.logger.errorPair("Can't get skychunk names", sql)
         finally:
             rs.close()
 
-        return configs
-
-    '''
-    Prompts user for info about a new or existing config and lets them neter the various details
-    '''
-    def editConfig(self):
+        return skychunks
+
+    '''
+    Prompts user for info about a new or existing skychunk and lets them neter the various details
+    '''
+    def editSkychunk(self):
 
        print " ********************************************************************"
-       print " *              Config editor"
+       print " *              Skychunk editor"
        print " *"
-       response = raw_input(" * Name for new config, or existing config to edit? ")
+       response = raw_input(" * Name for new skychunk, or existing skychunk to edit? ")
        if response == "": return
-       self.config.name = response
-
-       # attempt to insert new config, if it already exists then carry on with update
-       sql = "INSERT INTO config (name) VALUES ('" + self.config.name + "')"
+       self.skychunk.name = response
+
+       # attempt to insert new skychunk, if it already exists then carry on with update
+       sql = "INSERT INTO skychunk (name) VALUES ('" + self.skychunk.name + "')"
        try:        
            self.execute(sql) 
        except: pass
 
-       # for each column in the config table
-       sql = "SHOW COLUMNS FROM config"
+       # for each column in the skychunk table
+       sql = "SHOW COLUMNS FROM skychunk"
        rs = self.executeQuery(sql)
        while (rs.next()):
@@ -887,8 +894,10 @@
            if field == 'timestamp': continue
            if field == 'name': continue
+           if field == 'ingested_det': continue
+           if field == 'ingested_obj': continue
 
            # get current value for this field, if any
            try:
-               rs2 = self.executeQuery("SELECT " + field + " FROM config WHERE name = '" + self.config.name + "'")
+               rs2 = self.executeQuery("SELECT " + field + " FROM skychunk WHERE name = '" + self.skychunk.name + "'")
                rs2.first()
                default = rs2.getString(1)
@@ -907,5 +916,5 @@
                if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'"
                else: quotes = ""
-               self.execute("UPDATE config SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.config.name + "'")
+               self.execute("UPDATE skychunk SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.skychunk.name + "'")
        
        print " *"
@@ -913,9 +922,9 @@
 
     '''
-    Returns config for this client
-    '''
-    def getConfigForThisClient(self, host, pid):
-
-        sql = "SELECT config \
+    Returns skychunk for this client
+    '''
+    def getSkychunkForThisClient(self, host, pid):
+
+        sql = "SELECT skychunk \
                FROM clients \
                WHERE host = '" + host + "' \
@@ -925,8 +934,8 @@
             rs = self.executeQuery(sql)
             rs.first()
-            self.config.name = rs.getString(1)
-        except:
-            self.logger.errorPair("No config set for", "%s (pid=%d)" % (host, pid))
-            self.config.isLoaded = False
+            self.skychunk.name = rs.getString(1)
+        except:
+            self.logger.errorPair("No skychunk set for", "%s (pid=%d)" % (host, pid))
+            self.skychunk.isLoaded = False
             return False
 
@@ -934,12 +943,12 @@
 
     '''
-    Reads config from the database and populates Config object
-    '''
-    def readConfig(self, host, pid):
-
-        # first get config defined for this client
-        if not self.getConfigForThisClient(host, pid): return False
-
-        # now load that config
+    Reads skychunk from the database and populates Skychunk object
+    '''
+    def readSkychunk(self, host, pid):
+
+        # first get skychunk defined for this client
+        if not self.getSkychunkForThisClient(host, pid): return False
+
+        # now load that skychunk
         sql = "SELECT \
         datastore_product \
@@ -964,48 +973,59 @@
         ,queue_ST \
         ,queue_OB \
-        FROM config \
-        WHERE name = '" + self.config.name + "'"
-
-        self.config.batchTypes = []
-        try:
-            rs = self.executeQuery(sql)
+        ,parallel \
+        FROM skychunk \
+        WHERE name = '" + self.skychunk.name + "'"
+
+        self.skychunk.batchTypes = []
+        try:
+            rs = self.executeQuery(sql)
+
             rs.first()
-            self.config.datastoreProduct = rs.getString(1)
-            self.config.datastoreType = rs.getString(2)
-            if rs.getInt(3) == 1: self.config.datastorePublishing = True
-            else: self.config.datastorePublishing = False
-            self.config.dvoLabel = rs.getString(4)
+            self.skychunk.datastoreProduct = rs.getString(1)
+            self.skychunk.datastoreType = rs.getString(2)
+            if rs.getInt(3) == 1: self.skychunk.datastorePublishing = True
+            else: self.skychunk.datastorePublishing = False
+            self.skychunk.dvoLabel = rs.getString(4)
 
             # if dvoLabel is null is can break queries, so set to something
-            if not self.config.dvoLabel: self.config.dvoLabel = "none"
-            self.config.dvoLocation = rs.getString(5)
-            self.config.minRa = rs.getDouble(6)
-            self.config.maxRa = rs.getDouble(7)
-            self.config.minDec = rs.getDouble(8)
-            self.config.maxDec = rs.getDouble(9)
-
-            self.config.boxSize = rs.getDouble(10)
-            self.config.halfBox = self.config.boxSize/2.0
-            self.config.boxSizeWithBorder = self.config.boxSize + (self.config.BORDER * 2)
-
-            self.config.basePath = rs.getString(11)
-            self.config.dataRelease = rs.getInt(12)
-            self.config.deleteLocal = rs.getInt(13)
-            self.config.deleteDatastore = rs.getInt(14)
-            self.config.deleteDxLayer = rs.getInt(15)
-            self.config.epoch = rs.getString(16)
-            self.config.survey = rs.getString(17)
-            self.config.pspsSurvey = rs.getString(18)
-            if rs.getInt(19) == 1: self.config.batchTypes.append("P2")
-            if rs.getInt(20) == 1: self.config.batchTypes.append("ST")
-            if rs.getInt(21) == 1: self.config.batchTypes.append("OB")
-            self.config.force = False # TODO
-            self.config.test = False # TODO
-            self.config.isLoaded = True
-        except:
-            self.logger.errorPair("Could not read config with name", self.config.name)
-            self.config.isLoaded = False
-
-        return self.config.isLoaded
+            if not self.skychunk.dvoLabel: self.skychunk.dvoLabel = "none"
+            self.skychunk.dvoLocation = rs.getString(5)
+            self.skychunk.minRa = rs.getDouble(6)
+            self.skychunk.maxRa = rs.getDouble(7)
+            self.skychunk.minDec = rs.getDouble(8)
+            self.skychunk.maxDec = rs.getDouble(9)
+
+            self.skychunk.boxSize = rs.getDouble(10)
+            self.skychunk.halfBox = self.skychunk.boxSize/2.0
+            self.skychunk.boxSizeWithBorder = self.skychunk.boxSize + (self.skychunk.BORDER * 2)
+
+            self.skychunk.basePath = rs.getString(11)
+            self.skychunk.dataRelease = rs.getInt(12)
+
+            self.skychunk.deleteLocal = rs.getInt(13)
+            self.skychunk.deleteDatastore = rs.getInt(14)
+            self.skychunk.deleteDxLayer = rs.getInt(15)
+
+            self.skychunk.epoch = rs.getString(16)
+
+            self.skychunk.survey = rs.getString(17)
+            self.skychunk.pspsSurvey = rs.getString(18)
+
+            if rs.getInt(19) == 1: self.skychunk.batchTypes.append("P2")
+            if rs.getInt(20) == 1: self.skychunk.batchTypes.append("ST")
+            if rs.getInt(21) == 1: self.skychunk.batchTypes.append("OB")
+
+            self.skychunk.force = True # TODO
+            self.skychunk.parallel = False # TODO
+
+            if rs.getInt(22) == 1: self.skychunk.parallel = True
+
+            if self.skychunk.parallel: print "USING parallel"
+            self.skychunk.isLoaded = True
+        except:
+            self.logger.errorPair("Could not read skychunk with name", self.skychunk.name)
+            self.skychunk.isLoaded = False
+
+        return self.skychunk.isLoaded
 
     '''
@@ -1015,8 +1035,8 @@
 
         sql = "SELECT id FROM box \
-               WHERE config  = '" + self.config.name + "' \
+               WHERE skychunk  = '" + self.skychunk.name + "' \
                AND ra_center = " + str(ra) + " \
                AND dec_center = " + str(dec) + " \
-               AND box_side = " + str(self.config.boxSize)
+               AND box_side = " + str(self.skychunk.boxSize)
 
         id = -1
@@ -1034,5 +1054,5 @@
     '''
     def removeAllBoxes(self):
-        self.execute("DELETE FROM box WHERE config = '" + self.config.name + "'")
+        self.execute("DELETE FROM box WHERE skychunk = '" + self.skychunk.name + "'")
 
     '''
@@ -1047,7 +1067,7 @@
 
             sql = "INSERT INTO box \
-                   (config, ra_center, dec_center, box_side) \
+                   (skychunk, ra_center, dec_center, box_side) \
                    VALUES \
-                   ('" + self.config.name + "', " + str(ra) + ", " + str(dec) + ", " + str(self.config.boxSize) + ")"
+                   ('" + self.skychunk.name + "', " + str(ra) + ", " + str(dec) + ", " + str(self.skychunk.boxSize) + ")"
 
             self.execute(sql)
@@ -1055,4 +1075,48 @@
 
         return id
+
+    '''
+    Inserts new box into box table. If it already exisits, it returns existing box id 
+    '''
+    def isBoxIngested(self, id):
+
+        # set the field 'ingested' to 1 for this box
+        sql = "select ingested from box where id = " + str(id)
+        try:
+            rs = self.executeQuery(sql)
+            if not rs.next():
+                print "no matching boxes for ", str(id)
+                raise
+            status = rs.getInt(1)
+        except:
+            print "failed to set box ", str(id), "as ingested"
+            raise
+
+        return status
+    '''
+    Inserts new box into box table. If it already exisits, it returns existing box id 
+    '''
+    def setIngestedBox(self, id):
+
+        # set the field 'ingested' to 1 for this box
+        sql = "update box set ingested = 1 where id = " + str(id)
+        try:
+            self.execute(sql)
+        except:
+            print "failed to set box ", str(id), "as ingested"
+            raise
+
+    '''
+    Inserts new box into box table. If it already exisits, it returns existing box id 
+    '''
+    def clearIngestedBoxes(self):
+
+        # set the field 'ingested' to 1 for this box
+        sql = "update box set ingested = 0"
+        try:
+            self.execute(sql)
+        except:
+            print "failed to clear boxes as ingested"
+            raise
 
     '''
@@ -1088,11 +1152,13 @@
                FROM box \
                JOIN pending ON (id = box_id) \
-               WHERE config = '" + self.config.name + "' \
+               WHERE skychunk = '" + self.skychunk.name + "' \
                AND batch_type = '" + batchType + "' \
                AND ra_center NOT IN \
                (SELECT ra_center \
                 FROM stripe \
-                WHERE config = '" + self.config.name + "') \
+                WHERE skychunk = '" + self.skychunk.name + "') \
                GROUP BY ra_center LIMIT 1"
+
+        # XXX print "sql: ", sql               
 
         try:
@@ -1106,5 +1172,5 @@
                    FROM box \
                    JOIN pending ON (id = box_id) \
-                   WHERE config = '" + self.config.name + "' \
+                   WHERE skychunk = '" + self.skychunk.name + "' \
                    AND batch_type = '" + batchType + "' \
                    GROUP BY ra_center \
@@ -1126,5 +1192,5 @@
                WHERE ra_center = " + str(raCenter) + " \
                AND batch_type = '" + batchType + "' \
-               AND config = '" + self.config.name + "' \
+               AND skychunk = '" + self.skychunk.name + "' \
                ORDER BY dec_center DESC"
 
@@ -1159,6 +1225,6 @@
         # now insert new stripe entry
         sql = "INSERT INTO stripe \
-               (client_id, config, ra_center) \
-               SELECT clients.id, clients.config, " + str(raCenter) + " \
+               (client_id, skychunk, ra_center) \
+               SELECT clients.id, clients.skychunk, " + str(raCenter) + " \
                FROM clients \
                WHERE host = '" + host + "' \
@@ -1188,5 +1254,5 @@
 
     '''
-    Returns ids for pending items for this config
+    Returns ids for pending items for this skychunk
     '''
     def getPendingIds(self, batchType):
@@ -1195,5 +1261,5 @@
                FROM pending \
                JOIN box ON (box_id = id) \
-               WHERE config = '" + self.config.name + "' \
+               WHERE skychunk = '" + self.skychunk.name + "' \
                AND batch_type = '" + batchType + "'"
 
@@ -1204,5 +1270,5 @@
             rs.close()
         except:
-            self.logger.errorPair("Can't get pending ids for this config", sql)
+            self.logger.errorPair("Can't get pending ids for this skychunk", sql)
 
         return ids
@@ -1235,10 +1301,10 @@
                WHERE stage_id = " + str(stageID) + " \
                AND batch_type = '" + batchType + "' \
-               AND config = '" + self.config.name + "'"
+               AND skychunk = '" + self.skychunk.name + "'"
 
         self.execute(sql)
 
     '''
-    Writes density-plot data to file for pending stuff over sky for given config
+    Writes density-plot data to file for pending stuff over sky for given skychunk
     '''
     def createPendingDensityPlotData(self, batchType, DATFILE):
@@ -1246,5 +1312,5 @@
         sql = "SELECT id, ra_center, dec_center \
                FROM box \
-               WHERE config = '" + self.config.name + "' \
+               WHERE skychunk = '" + self.skychunk.name + "' \
                ORDER BY ra_center, dec_center"
 
@@ -1299,5 +1365,5 @@
     def getItemsInThisThisBox(self, ra, dec):
 
-        halfSide = self.config.boxSize/2.0
+        halfSide = self.skychunk.boxSize/2.0
         minRa =  ra-halfSide
         maxRa = ra+halfSide
@@ -1328,5 +1394,5 @@
                FROM stripe \
                JOIN clients ON (client_id = id) \
-               WHERE clients.config = '" + self.config.name + "' \
+               WHERE clients.skychunk = '" + self.skychunk.name + "' \
                ORDER BY host, started"
 
