Index: /tags/ipp-20101029/ippTasks/publish.pro
===================================================================
--- /tags/ipp-20101029/ippTasks/publish.pro	(revision 29722)
+++ /tags/ipp-20101029/ippTasks/publish.pro	(revision 29723)
@@ -15,7 +15,4 @@
 
 macro publish.on
-  task publish.trigger
-    active true
-  end
   task publish.load
     active true
@@ -30,7 +27,4 @@
 
 macro publish.off
-  task publish.trigger
-    active false
-  end
   task publish.load
     active false
@@ -59,54 +53,6 @@
 
 # this variable will cycle through the known database names
-$publish_trigger_DB = 0
 $publish_load_DB = 0
 $publish_revert_DB = 0
-
-task	       publish.trigger
-  host         local
-
-  periods      -poll $LOADPOLL
-  periods      -exec $LOADEXEC
-  periods      -timeout 30
-  npending     1
-
-  stdout NULL
-  stderr $LOGDIR/publish.trigger.log
-
-  task.exec
-    if ($LABEL:n == 0) break
-    #otherwise everything will be queued when there is no label.
-    $run = pubtool -definerun
-    if ($DB:n == 0)
-      option DEFAULT
-    else
-      # save the DB name for the exit tasks
-      option $DB:$publish_trigger_DB
-      $run = $run -dbname $DB:$publish_trigger_DB
-      $publish_trigger_DB ++
-      if ($publish_trigger_DB >= $DB:n) set publish_trigger_DB = 0
-    end
-    add_poll_labels run
-    command $run
-  end
-
-  # success
-  task.exit    0
-  end
-
-  # locked list
-  task.exit    default
-    showcommand failure
-  end
-
-  task.exit    crash
-    showcommand crash
-  end
-
-  # operation times out?
-  task.exit    timeout
-    showcommand timeout
-  end
-end
 
 task	       publish.load
Index: /tags/ipp-20101029/ippTasks/survey.pro
===================================================================
--- /tags/ipp-20101029/ippTasks/survey.pro	(revision 29722)
+++ /tags/ipp-20101029/ippTasks/survey.pro	(revision 29723)
@@ -32,4 +32,5 @@
  book create SURVEY_CHIP_BG
  book create SURVEY_WARP_BG
+ book create SURVEY_PUBLISH
  $haveSurveyBooks = TRUE
 end
@@ -44,4 +45,5 @@
 $SURVEY_CHIP_BG_DB = 0
 $SURVEY_WARP_BG_DB = 0
+$SURVEY_PUBLISH_DB = 0
 
 $SURVEY_EXEC = 120
@@ -77,4 +79,7 @@
     active true
   end
+  task survey.publish
+    active true
+  end
 end
 
@@ -105,4 +110,7 @@
   end
   task survey.warp.bg
+    active false
+  end
+  task survey.publish
     active false
   end
@@ -355,4 +363,32 @@
   book listbook SURVEY_WARP_BG
 end
+
+# user functions to manipulate publish labels
+macro survey.add.publish
+  if ($0 != 3)
+    echo "USAGE: survey.add.publish (label) (client_id)"
+    break
+  end
+  book newpage SURVEY_PUBLISH $1
+  book setword SURVEY_PUBLISH $1 CLIENT_ID $2
+  book setword SURVEY_PUBLISH $1 STATE PENDING
+end
+
+macro survey.del.publish
+  if ($0 != 2)
+    echo "USAGE: survey.del.publish (label)"
+    break
+  end
+  book delpage SURVEY_PUBLISH $1
+end
+
+macro survey.show.publish
+  if ($0 != 1)
+    echo "USAGE: survey.show.publish"
+    break
+  end
+  book listbook SURVEY_PUBLISH
+end
+
 
 task survey.diff
@@ -579,5 +615,5 @@
     end
     
-    echo $run
+    # echo $run
     command $run
   end
@@ -651,5 +687,5 @@
     end
     
-    echo $run
+    # echo $run
     command $run
   end
@@ -674,4 +710,5 @@
   end
 end
+
 
 task survey.addstar
@@ -723,5 +760,5 @@
     
     $run = $run -definebyquery -destreaked -label $label -set_dvodb $dvodb -set_minidvodb_group $minidvodb_group -set_minidvodb -set_label $minidvodb_group
-    echo $run
+    # echo $run
     command $run
   end
@@ -934,5 +971,5 @@
     end
     
-    echo $run
+    # echo $run
     command $run
   end
@@ -1004,5 +1041,5 @@
     end
     
-    echo $run
+    # echo $run
     command $run
   end
@@ -1027,2 +1064,72 @@
   end
 end
+
+task survey.publish
+  host local
+ 
+  periods      -poll $SURVEY_POLL
+  periods      -exec $SURVEY_EXEC
+  periods      -timeout $SURVEY_TIMEOUT
+  npending     1
+
+  stdout $LOGDIR/survey.publish.log
+  stderr $LOGDIR/survey.publish.log
+
+  # generate publish runs
+  task.exec
+    book npages SURVEY_PUBLISH -var N
+    if ($N == 0)
+    #  echo "No labels for processing"
+      break
+    endif
+
+    book getpage SURVEY_PUBLISH 0 -var label -key STATE NEW
+    if ("$label" == "NULL")
+      # All labels have been done --- reset
+      echo "Resetting labels"
+      for i 0 $N
+        book getpage SURVEY_PUBLISH $i -var label
+	book setword SURVEY_PUBLISH $label STATE NEW
+      end
+      book getpage SURVEY_PUBLISH 0 -var label -key STATE NEW
+
+      # Select different database
+      $SURVEY_PUBLISH ++
+      if ($SURVEY_PUBLISH >= $DB:n) set SURVEY_PUBLISH = 0
+    end
+
+    book setword SURVEY_PUBLISH $label STATE DONE
+    book getword SURVEY_PUBLISH $label CLIENT_ID -var client_id
+  
+    $run = pubtool -definerun -label $label -client_id $client_id
+
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      $run = $run -dbname $DB:$SURVEY_PUBLISH
+      option $DB:$SURVEY_PUBLISH
+    end
+    
+    #echo $run
+    command echo $run
+  end
+
+  # success
+  task.exit    0
+    #echo "Success"
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
