Index: src/hg/lib/cart.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/cart.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -b -B -U 4 -r1.114 -r1.115
--- src/hg/lib/cart.c	9 Dec 2009 03:35:50 -0000	1.114
+++ src/hg/lib/cart.c	4 Jan 2010 19:12:28 -0000	1.115
@@ -1651,49 +1651,30 @@
     }
 return dyStringCannibalize(&orderDY);
 }
 
-char *cartLookUpVariableClosestToHome(struct cart *cart, struct trackDb *tdb, boolean compositeLevel, char *suffix,char **pVariable)
-/* Returns value or NULL for a cart variable from lowest level on up:
-   subtrackName.suffix, then compositeName.view.suffix, then compositeName.suffix
-   Optionally fills the non NULL pVariable with the actual name of the variable in the cart */
-{
-char buf[512];
-safef(buf, sizeof buf, "%s.%s", tdb->tableName,suffix);
-
-char *cartSetting = NULL;
-if(!compositeLevel)
-    cartSetting = hashFindVal(cart->hash, buf);
-if( cartSetting == NULL && tdbIsCompositeChild(tdb))
-    {
-    char *stView = NULL;
-    if(subgroupFind(tdb,"view",&stView))
-        {
-        if(!compositeLevel)
-            {
-            safef(buf, sizeof buf, "%s.%s.%s", tdb->tableName,stView,suffix);
-            cartSetting = hashFindVal(cart->hash, buf);
-            }
-        if(cartSetting == NULL)
-            {
-            safef(buf, sizeof buf, "%s.%s.%s", tdb->parent->tableName,stView,suffix);
-            cartSetting = hashFindVal(cart->hash, buf);
-            }
-        }
-    if(cartSetting == NULL)
+char *cartLookUpVariableClosestToHome(struct cart *cart, struct trackDb *tdb, 
+	boolean compositeLevel, char *suffix,char **pVariable)
+/* Returns value or NULL for a cart variable from lowest level on up. Optionally 
+ * fills the non NULL pVariable with the actual name of the variable in the cart */
+{
+if (compositeLevel)
+    tdb = tdb->parent;
+for ( ; tdb != NULL; tdb = tdb->parent)
+    {
+    char buf[512];
+    safef(buf, sizeof buf, "%s.%s", tdb->tableName,suffix);
+    char *cartSetting = hashFindVal(cart->hash, buf);
+    if (cartSetting != NULL)
         {
-        safef(buf, sizeof buf, "%s.%s", tdb->parent->tableName,suffix);
-        cartSetting = hashFindVal(cart->hash, buf);
+	if(pVariable != NULL)
+	    *pVariable = cloneString(buf);
+	return cartSetting;
         }
     }
-if(pVariable != NULL)
-    {
-    if(cartSetting != NULL)
-        *pVariable = cloneString(buf);
-    else
+if (pVariable != NULL)
         *pVariable = NULL;
-    }
-return cartSetting;
+return NULL;
 }
 
 // NEVER CHECKED IN.
 //#define NORMALIZE_CLOSEST_TO_HOME
@@ -1851,9 +1832,9 @@
 /* Return slName list (possibly with multiple values for the same var) from lowest level on up:
    subtrackName.suffix, then compositeName.view.suffix, then compositeName.suffix */
 {
 char *var = NULL;
-(void)cartLookUpVariableClosestToHome(cart,tdb,compositeLevel,suffix,&var);
+cartLookUpVariableClosestToHome(cart,tdb,compositeLevel,suffix,&var);
 if(var == NULL)
     return NULL;
 
 struct slName *slNames = cartOptionalSlNameList(cart,var);
@@ -1878,7 +1859,7 @@
 {
 cartRemoveAllForTdb(cart,tdb);
 struct trackDb *subTdb;
 for(subTdb=tdb->subtracks;subTdb!=NULL;subTdb=subTdb->next)
-    cartRemoveAllForTdb(cart,subTdb);
+    cartRemoveAllForTdbAndChildren(cart,subTdb);
 }
 

