--- loncom/lonnet/perl/lonnet.pm 2006/03/04 01:00:15 1.715 +++ loncom/lonnet/perl/lonnet.pm 2006/03/05 01:54:50 1.718 @@ -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.718 2006/03/05 01:54:50 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2855,6 +2855,13 @@ sub dump { return %returnhash; } +# --------------------------------------------------------- dumpstore interface + +sub dumpstore { + my ($namespace,$udomain,$uname,$regexp,$range)=@_; + return &dump($namespace,$udomain,$uname,$regexp,$range); +} + # -------------------------------------------------------------- keys interface sub getkeys { @@ -3005,12 +3012,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 +3026,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 @@ -6405,7 +6436,7 @@ sub clutter { && $thisfn!~/\.(sequence|page)$/) { $thisfn='/adm/coursedocs/showdoc'.$thisfn; } else { - &logthis("Got a blank emb style"); +# &logthis("Got a blank emb style"); } } } @@ -7226,6 +7257,27 @@ all args are optional =item * +dumpstore($namespace,$udom,$uname,$regexp,$range) : +dumps the complete (or key matching regexp) namespace into a hash +($udom, $uname, $regexp, $range are optional) for a namespace that is +normally &store()ed into + +$range should be either an integer '100' (give me the first 100 + matching records) + or be two integers sperated by a - with no spaces + '30-50' (give me the 30th through the 50th matching + records) + + +=item * + +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 * + tmpstore($storehash,$symb,$namespace,$udom,$uname) : storage that works very similar to store/cstore, but all data is stored in a temporary location and can be reset using tmpreset, $storehash should @@ -7279,17 +7331,6 @@ 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(). - -=item * - cput($namespace,$storehash,$udom,$uname) : critical put ($udom and $uname are optional)