--- loncom/lonnet/perl/lonnet.pm 2006/03/04 01:00:15 1.715 +++ loncom/lonnet/perl/lonnet.pm 2006/03/04 04:25:31 1.716 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.715 2006/03/04 01:00:15 albertel Exp $ +# $Id: lonnet.pm,v 1.716 2006/03/04 04:25:31 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3005,12 +3005,13 @@ sub putstore { $items.= &escape($key).'='.&freeze_escape($storehash->{$key}).'&'; } $items=~s/\&$//; - $symb=&escape($symb); - $version=&escape($version); + my $esc_symb=&escape($symb); + my $esc_v=&escape($version); my $reply = - &reply("putstore:$udomain:$uname:$namespace:$symb:$version:$items", + &reply("putstore:$udomain:$uname:$namespace:$esc_symb:$esc_v:$items", $uhome); if ($reply eq 'unknown_cmd') { + # gfall back to way things use to be done return &old_putstore($namespace,$symb,$version,$storehash,$udomain, $uname); } @@ -3018,7 +3019,30 @@ sub putstore { } sub old_putstore { - + my ($namespace,$symb,$version,$storehash,$udomain,$uname)=@_; + if (!$udomain) { $udomain=$env{'user.domain'}; } + if (!$uname) { $uname=$env{'user.name'}; } + my $uhome=&homeserver($uname,$udomain); + my %newstorehash; + foreach (keys %$storehash) { + my $key = $version.':'.&escape($symb).':'.$_; + $newstorehash{$key} = $storehash->{$_}; + } + my $items=''; + my %allitems = (); + foreach (keys %newstorehash) { + if ($_ =~ m/^([^\:]+):([^\:]+):([^\:]+)$/) { + my $key = $1.':keys:'.$2; + $allitems{$key} .= $3.':'; + } + $items.=$_.'='.&freeze_escape($newstorehash{$_}).'&'; + } + foreach (keys %allitems) { + $allitems{$_} =~ s/\:$//; + $items.= $_.'='.$allitems{$_}.'&'; + } + $items=~s/\&$//; + return &reply("put:$udomain:$uname:$namespace:$items",$uhome); } # ------------------------------------------------------ critical put interface @@ -7279,14 +7303,10 @@ put($namespace,$storehash,$udom,$uname) =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(). +putstore($namespace,$symb,$version,$storehash,$udomain,$uname) : + replaces a &store() version of data with a replacement set of data + for a particular resource in a namespace passed in the $storehash hash + reference =item *