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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 22 Jul 2004 23:08:44 -0000


raeburn		Thu Jul 22 19:08:44 2004 EDT

  Modified files:              
    /loncom	lond 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  &lonnet::putstore() is used to replace an existing record in a .db file previously 
  created using &lonnet::store, in a way that preserves the existing version information.
  Used instead of &lonnet::store when you want to update records for a $symb in a .db
  file but do not want to increment the version (and hence create new records).
  
  Modification to lond::put() required to support transfer of additional : separated
  values besides command,uname,udom etc. 
  
  
Index: loncom/lond
diff -u loncom/lond:1.205 loncom/lond:1.206
--- loncom/lond:1.205	Sat Jul  3 14:49:42 2004
+++ loncom/lond	Thu Jul 22 19:08:43 2004
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.205 2004/07/03 18:49:42 raeburn Exp $
+# $Id: lond,v 1.206 2004/07/22 23:08:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,7 +56,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.205 $'; #' stupid emacs
+my $VERSION='$Revision: 1.206 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -2232,11 +2232,14 @@
 # ------------------------------------------------------------------------- put
 		} elsif ($userinput =~ /^put/) {
 		    if(isClient) {
-			my ($cmd,$udom,$uname,$namespace,$what)
+			my ($cmd,$udom,$uname,$namespace,$what,@extras)
 			    =split(/:/,$userinput);
 			$namespace=~s/\//\_/g;
 			$namespace=~s/\W//g;
 			if ($namespace ne 'roles') {
+                            if (@extras) {
+                                $what .= ':'.join(':',@extras);
+                            }
 			    chomp($what);
 			    my $proname=propath($udom,$uname);
 			    my $now=time;
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.523 loncom/lonnet/perl/lonnet.pm:1.524
--- loncom/lonnet/perl/lonnet.pm:1.523	Thu Jul 22 18:12:06 2004
+++ loncom/lonnet/perl/lonnet.pm	Thu Jul 22 19:08:44 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.523 2004/07/22 22:12:06 raeburn Exp $
+# $Id: lonnet.pm,v 1.524 2004/07/22 23:08:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2591,6 +2591,30 @@
    return &reply("put:$udomain:$uname:$namespace:$items",$uhome);
 }
 
+# ---------------------------------------------------------- putstore interface
+                                                                                     
+sub putstore {
+   my ($namespace,$storehash,$udomain,$uname)=@_;
+   if (!$udomain) { $udomain=$ENV{'user.domain'}; }
+   if (!$uname) { $uname=$ENV{'user.name'}; }
+   my $uhome=&homeserver($uname,$udomain);
+   my $items='';
+   my %allitems = ();
+   foreach (keys %$storehash) {
+       if ($_ =~ m/^([^\:]+):([^\:]+):([^\:]+)$/) {
+           my $key = $1.':keys:'.$2;
+           $allitems{$key} .= $3.':';
+       }
+       $items.=$_.'='.&escape($$storehash{$_}).'&';
+   }
+   foreach (keys %allitems) {
+       $allitems{$_} =~ s/\:$//;
+       $items.= $_.'='.$allitems{$_}.'&';
+   }
+   $items=~s/\&$//;
+   return &reply("put:$udomain:$uname:$namespace:$items",$uhome);
+}
+
 # ------------------------------------------------------ critical put interface
 
 sub cput {
@@ -5918,6 +5942,17 @@
 
 =item *
 
+putstore($namespace,$storehash,$udomain,$uname) : stores hash in namesp
+keys used in storehash include version information (e.g., 1:$symb:message etc.) as
+used in records written by &store and retrieved by &restore.  This function 
+was created for use in editing discussion posts, without incrementing the
+version number included in the key for a particular post. The colon 
+separated list of attribute names (e.g., the value associated with the key 
+1:keys:$symb) is also generated and passed in the ampersand separated 
+items sent to lonnet::reply().  
+
+=item *
+
 cput($namespace,$storehash,$udom,$uname) : critical put
 ($udom and $uname are optional)