--- loncom/lonnet/perl/lonnet.pm	2001/06/01 19:32:40	1.128
+++ loncom/lonnet/perl/lonnet.pm	2001/07/26 20:26:43	1.131
@@ -41,11 +41,21 @@
 #                      if they aren't given they will be derived from the 
 #                      current enviroment
 # eget(namesp,array) : returns hash with keys from array filled in from namesp
-# get(namesp,array)  : returns hash with keys from array filled in from namesp
+# get(namesp,arrayref,udom,uname)
+#                    : returns hash with keys from array  reference filled
+#                      in from namesp
+#                           if supplied uses udom as the domain and uname
+#                           as the username for the dump (supply a courseid
+#                           for the uname if you want a course database)
+#                           if not supplied it uses %ENV to get the values
 # del(namesp,array)  : deletes keys out of array from namesp
 # put(namesp,hash)   : stores hash in namesp
 # cput(namesp,hash)  : critical put
-# dump(namesp)       : dumps the complete namespace into a hash
+# dump(namesp,udom,uname) : dumps the complete namespace into a hash
+#                           if supplied uses udom as the domain and uname
+#                           as the username for the dump (supply a courseid
+#                           for the uname if you want a course database)
+#                           if not supplied it uses %ENV to get the values
 # ssi(url,hash)      : does a complete request cycle on url to localhost, posts
 #                      hash
 # coursedescription(id) : returns and caches course description for id
@@ -784,22 +794,18 @@ sub coursedescription {
     $courseid=~s/^\///;
     $courseid=~s/\_/\//g;
     my ($cdomain,$cnum)=split(/\//,$courseid);
-    my $chome=homeserver($cnum,$cdomain);
+    my $chome=&homeserver($cnum,$cdomain);
     if ($chome ne 'no_host') {
-       my $rep=reply("dump:$cdomain:$cnum:environment",$chome);
-       if ($rep ne 'con_lost') {
+       my %returnhash=&dump('environment',$cdomain,$cnum);
+       if (!exists($returnhash{'con_lost'})) {
            my $normalid=$cdomain.'_'.$cnum;
            my %envhash=();
-           my %returnhash=('home'   => $chome, 
-                           'domain' => $cdomain,
-                           'num'    => $cnum);
-           map {
-               my ($name,$value)=split(/\=/,$_);
-               $name=&unescape($name);
-               $value=&unescape($value);
-               $returnhash{$name}=$value;
+           $returnhash{'home'}= $chome;
+	   $returnhash{'domain'} = $cdomain;
+	   $returnhash{'num'} = $cnum;
+           while (my ($name,$value) = each %returnhash) {
                $envhash{'course.'.$normalid.'.'.$name}=$value;
-           } split(/\&/,$rep);
+           }
            $returnhash{'url'}='/res/'.declutter($returnhash{'url'});
            $returnhash{'fn'}=$perlvar{'lonDaemons'}.'/tmp/'.
 	       $ENV{'user.name'}.'_'.$cdomain.'_'.$cnum;
@@ -916,21 +922,26 @@ sub rolesinit {
 # --------------------------------------------------------------- get interface
 
 sub get {
-   my ($namespace,@storearr)=@_;
+   my ($namespace,$storearr,$udomain,$uname)=@_;
+   &logthis("from :$udomain:$uname: I got ref :$storearr:");
    my $items='';
    map {
        $items.=escape($_).'&';
-   } @storearr;
+   } @$storearr;
    $items=~s/\&$//;
- my $rep=reply("get:$ENV{'user.domain'}:$ENV{'user.name'}:$namespace:$items",
-                 $ENV{'user.home'});
+   &logthis("and made :$items:");
+   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
+   if (!$uname) { $uname=$ENV{'user.name'}; }
+   my $uhome=&homeserver($uname,$udomain);
+
+   my $rep=reply("get:$udomain:$uname:$namespace:$items",$uhome);
    my @pairs=split(/\&/,$rep);
    my %returnhash=();
    my $i=0;
    map {
       $returnhash{$_}=unescape($pairs[$i]);
       $i++;
-   } @storearr;
+   } @$storearr;
    return %returnhash;
 }
 
@@ -950,9 +961,11 @@ sub del {
 # -------------------------------------------------------------- dump interface
 
 sub dump {
-   my $namespace=shift;
-   my $rep=reply("dump:$ENV{'user.domain'}:$ENV{'user.name'}:$namespace",
-                $ENV{'user.home'});
+   my ($namespace,$udomain,$uname)=@_;
+   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
+   if (!$uname) { $uname=$ENV{'user.name'}; }
+   my $uhome=&homeserver($uname,$udomain);
+   my $rep=reply("dump:$udomain:$uname:$namespace",$uhome);
    my @pairs=split(/\&/,$rep);
    my %returnhash=();
    map {
@@ -1704,7 +1717,7 @@ sub EXT {
 # ---------------------------------------------------- Any other user namespace
         } else {
             my $item=($rest)?$qualifier.'.'.$rest:$qualifier;
-            my %reply=&get($space,$item);
+            my %reply=&get($space,[$item]);
             return $reply{$item};
         }
     } elsif ($realm eq 'request') {
@@ -1747,7 +1760,7 @@ sub EXT {
 
 # ----------------------------------------------------------- first, check user
          my %resourcedata=get('resourcedata',
-                           ($courselevelr,$courselevelm,$courselevel));
+                           [$courselevelr,$courselevelm,$courselevel]);
          if (($resourcedata{$courselevelr}!~/^error\:/) &&
              ($resourcedata{$courselevelr}!~/^con_lost/)) {