[LON-CAPA-cvs] cvs: loncom / lond /interface lonspreadsheet.pm /lonnet/perl lonnet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 15 Jan 2003 19:34:03 -0000


matthew		Wed Jan 15 14:34:03 2003 EDT

  Modified files:              
    /loncom	lond 
    /loncom/interface	lonspreadsheet.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Rename dumpcurrent to currentdump
  lond: fixed 1D10T bug in code.  $value was used instead of $v (version).
  lonspreadsheet: now call lonnet::currentdump, removed debugging code and
                  code that was commented out.
  lonnet:renamed dumpcurrent to currentdump.  currentdump will now deal 
         transparently with old lond's that do not support currentdump.
  
  
Index: loncom/lond
diff -u loncom/lond:1.106 loncom/lond:1.107
--- loncom/lond:1.106	Tue Jan 14 23:43:14 2003
+++ loncom/lond	Wed Jan 15 14:34:02 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.106 2003/01/15 04:43:14 foxr Exp $
+# $Id: lond,v 1.107 2003/01/15 19:34:02 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1222,7 +1222,7 @@
                            print $client "error:$!\n";
                        }
 # ----------------------------------------------------------------- dumpcurrent
-                   } elsif ($userinput =~ /^dumpcurrent/) {
+                   } elsif ($userinput =~ /^currentdump/) {
                        my ($cmd,$udom,$uname,$namespace)
                           =split(/:/,$userinput);
                        $namespace=~s/\//\_/g;
@@ -1244,9 +1244,8 @@
                               next if (exists($data{$symb}) && 
                                        exists($data{$symb}->{$param}) &&
                                        $data{$symb}->{'v.'.$param} > $v);
-                              #&logthis("v = ".$v." p = ".$param." s = ".$symb);
                               $data{$symb}->{$param}=$value;
-                              $data{$symb}->{'v.'.$param}=$value;
+                              $data{$symb}->{'v.'.$param}=$v;
                            }
                            if (untie(%hash)) {
                              while (my ($symb,$param_hash) = each(%data)) {
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.162 loncom/interface/lonspreadsheet.pm:1.163
--- loncom/interface/lonspreadsheet.pm:1.162	Mon Jan 13 16:52:11 2003
+++ loncom/interface/lonspreadsheet.pm	Wed Jan 15 14:34:03 2003
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.162 2003/01/13 21:52:11 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.163 2003/01/15 19:34:03 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2417,18 +2417,11 @@
     my %formulas=&getformulas($sheet);
     $cachedassess=$sheet->{'uname'}.':'.$sheet->{'udom'};
     # Get ALL the student preformance data
-    my @tmp = &Apache::lonnet::dumpcurrent($sheet->{'cid'},
-#    my @tmp = &Apache::lonnet::dump($sheet->{'cid'},
+    my @tmp = &Apache::lonnet::currentdump($sheet->{'cid'},
                                            $sheet->{'udom'},
-                                           $sheet->{'uname'},
-                                           undef);
+                                           $sheet->{'uname'});
     if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
         %cachedstores = @tmp;
-#        &Apache::lonnet::logthis("-------------------------------------");
-#        foreach (keys(%cachedstores)) {
-#            &Apache::lonnet::logthis("data for ".$_);
-#        }
-#        &Apache::lonnet::logthis("-------------------------------------");
     }
     undef @tmp;
     # 
@@ -2557,17 +2550,9 @@
         #
         # get data out of the dumped stores
         # 
-#        my $version=$cachedstores{'version:'.$symb};
-#        my $scope;
-#        for ($scope=1;$scope<=$version;$scope++) {
-#            foreach (split(/\:/,$cachedstores{$scope.':keys:'.$symb})) {
-#                $returnhash{$_}=$cachedstores{$scope.':'.$symb.':'.$_};
-#            } 
-#        }
         if (exists($cachedstores{$symb})) {
             %returnhash = %{$cachedstores{$symb}};
         } else {
-#            &Apache::lonnet::logthis("No data for ".$symb);
             %returnhash = ();
         }
     } else {
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.318 loncom/lonnet/perl/lonnet.pm:1.319
--- loncom/lonnet/perl/lonnet.pm:1.318	Mon Jan 13 16:52:11 2003
+++ loncom/lonnet/perl/lonnet.pm	Wed Jan 15 14:34:03 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.318 2003/01/13 21:52:11 matthew Exp $
+# $Id: lonnet.pm,v 1.319 2003/01/15 19:34:03 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1744,21 +1744,53 @@
    return %returnhash;
 }
 
-# --------------------------------------------------------------- dumpcurrent
-sub dumpcurrent {
+# --------------------------------------------------------------- currentdump
+sub currentdump {
    my ($namespace,$udomain,$uname)=@_;
    if (!$udomain) { $udomain = $ENV{'user.domain'}; }
    if (!$uname)   { $uname   = $ENV{'user.name'};   }
    my $uhome = &homeserver($uname,$udomain);
-   my $rep=reply("dumpcurrent:$udomain:$uname:$namespace",$uhome);
-   &logthis("error = ".$rep) if ($rep =~ /^(error|no_such_host)/);
+   my $rep=reply("currentdump:$udomain:$uname:$namespace",$uhome);
    return if ($rep =~ /^(error:|no_such_host)/);
-   my @pairs=split(/\&/,$rep);
+   #
    my %returnhash=();
-   foreach (@pairs) {
-      my ($key,$value)=split(/=/,$_);
-      my ($symb,$param) = split(/:/,$key);
-      $returnhash{&unescape($symb)}->{&unescape($param)} = &unescape($value);
+   #
+   if ($rep eq "unknown_cmd") { 
+       # an old lond will not know currentdump
+       # Do a dump and make it look like a currentdump
+       my @tmp = &dump($namespace,$udomain,$uname,'.');
+       return if ($tmp[0] =~ /^(error:|no_such_host)/);
+       my %hash = @tmp;
+       @tmp=();
+       # Code ripped from lond, essentially.  The only difference
+       # here is the unescaping done by lonnet::dump().  Conceivably
+       # we might run in to problems with parameter names =~ /^v\./
+       while (my ($key,$value) = each(%hash)) {
+           my ($v,$symb,$param) = split(/:/,$key);
+           next if ($v eq 'version' || $symb eq 'keys');
+           next if (exists($returnhash{$symb}) &&
+                    exists($returnhash{$symb}->{$param}) &&
+                    $returnhash{$symb}->{'v.'.$param} > $v);
+           $returnhash{$symb}->{$param}=$value;
+           $returnhash{$symb}->{'v.'.$param}=$v;
+       }
+       #
+       # Remove all of the keys in the hashes which keep track of
+       # the version of the parameter.
+       while (my ($symb,$param_hash) = each(%returnhash)) {
+           # use a foreach because we are going to delete from the hash.
+           foreach my $key (keys(%$param_hash)) {
+               delete($param_hash->{$key}) if ($key =~ /^v\./);
+           }
+       }
+   } else {
+       my @pairs=split(/\&/,$rep);
+       foreach (@pairs) {
+           my ($key,$value)=split(/=/,$_);
+           my ($symb,$param) = split(/:/,$key);
+           $returnhash{&unescape($symb)}->{&unescape($param)} = 
+                                                          &unescape($value);
+       }
    }
    return %returnhash;
 }