[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm

www lon-capa-cvs@mail.lon-capa.org
Wed, 12 Jan 2005 16:18:54 -0000


www		Wed Jan 12 11:18:54 2005 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Cannot get the push-business to work. Saving my work for later.
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.181 loncom/publisher/lonpublisher.pm:1.182
--- loncom/publisher/lonpublisher.pm:1.181	Wed Jan  5 15:11:19 2005
+++ loncom/publisher/lonpublisher.pm	Wed Jan 12 11:18:54 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.181 2005/01/05 20:11:19 www Exp $
+# $Id: lonpublisher.pm,v 1.182 2005/01/12 16:18:54 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -138,6 +138,8 @@
 my $cuname;
 my $cudom;
 
+my $registered_cleanup;
+
 =pod
 
 =item B<metaeval>
@@ -1543,10 +1545,13 @@
     $r->rflush;
 
 # ------------------------------------------------------------- Trigger updates
-    $ENV{'internal.publication.target'}=$target;
-    $ENV{'internal.publication.source'}=$source;
-    $r->register_cleanup(\&notify);
-
+    print $logfile("\nRegistering for notifications: $target $source\n");
+    push(@{$ENV{'internal.publication.targetsource'}},[$target,$source]);
+    unless ($registered_cleanup) {
+	&Apache::lonnet::logthis('Cleanup handler registered');
+	$r->register_cleanup(\&notify);
+	$registered_cleanup=1;
+    }
 # ------------------------------------------------ Provide link to new resource
     unless ($batch) {
         my $thisdistarget=$target;
@@ -1575,36 +1580,39 @@
 # =============================================================== Notifications
 sub notify {  
 # --------------------------------------------------- Send update notifications
-    my $target=$ENV{'internal.publication.target'};
-    my $source=$ENV{'internal.publication.source'};
-    my $logfile=Apache::File->new('>>'.$source.'.log');
-    print $logfile "\nCleanup phase: Notifications\n";
-    my @subscribed=&get_subscribed_hosts($target);
-    foreach my $subhost (@subscribed) {
-	print $logfile "\nNotifying host ".$subhost.':';
-	my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
-	print $logfile $reply;
-    }
+    &Apache::lonnet::logthis('Cleanup Phase Publication Handler');
+    foreach my $targetsource (@{$ENV{'internal.publication.targetsource'}}){
+	my ($target,$source)=@{$targetsource};
+	my $logfile=Apache::File->new('>>'.$source.'.log');
+	print $logfile "\nCleanup phase: Notifications\n";
+	my @subscribed=&get_subscribed_hosts($target);
+	foreach my $subhost (@subscribed) {
+	    print $logfile "\nNotifying host ".$subhost.':';
+	    my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
+	    print $logfile $reply;
+	}
 # ---------------------------------------- Send update notifications, meta only
-    my @subscribedmeta=&get_subscribed_hosts("$target.meta");
-    foreach my $subhost (@subscribedmeta) {
-	print $logfile "\nNotifying host for metadata only ".$subhost.':';
-	my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
-					    $subhost);
-	print $logfile $reply;
-    } 
+	my @subscribedmeta=&get_subscribed_hosts("$target.meta");
+	foreach my $subhost (@subscribedmeta) {
+	    print $logfile "\nNotifying host for metadata only ".$subhost.':';
+	    my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
+						$subhost);
+	    print $logfile $reply;
+	} 
 # --------------------------------------------------- Notify subscribed courses
-    my %courses=&coursedependencies($target);
-    my $now=time;
-    foreach (keys %courses) {
-	print $logfile "\nNotifying course ".$_.':';
-        my ($cdom,$cname)=split(/\_/,$_);
-	my $reply=&Apache::lonnet::cput
-                  ('versionupdate',{$target => $now},$cdom,$cname);
-	print $logfile $reply;
+	my %courses=&coursedependencies($target);
+	my $now=time;
+	foreach (keys %courses) {
+	    print $logfile "\nNotifying course ".$_.':';
+	    my ($cdom,$cname)=split(/\_/,$_);
+	    my $reply=&Apache::lonnet::cput
+		('versionupdate',{$target => $now},$cdom,$cname);
+	    print $logfile $reply;
+	}
+	print $logfile "\n============ Done ============\n";
+	$logfile->close();
     }
-    print $logfile "\n============ Done ============\n";
-    $logfile->close();
+    return OK;
 }
 
 #########################################
@@ -1816,6 +1824,8 @@
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['filename']);
 
+# ------------------------------------------------- Flag for registered cleanup
+    $registered_cleanup=0;
 # -------------------------------------------------------------- Check filename
 
     my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});