[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 24 Jun 2002 14:16:58 -0000
www Mon Jun 24 10:16:58 2002 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
Toward bug 305: &symbread now recognizes "mapalias" names and returns symb.
Also, if &symbread is handed a symb, it verifies the symb and returns it
"cleaned" if okay.
In effect, &symbread can now be handed symbs, URLs, and aliases, and should
return a cleaned verified symb in any of those cases.
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.241 loncom/lonnet/perl/lonnet.pm:1.242
--- loncom/lonnet/perl/lonnet.pm:1.241 Tue Jun 18 15:39:13 2002
+++ loncom/lonnet/perl/lonnet.pm Mon Jun 24 10:16:58 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.241 2002/06/18 19:39:13 www Exp $
+# $Id: lonnet.pm,v 1.242 2002/06/24 14:16:58 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1840,6 +1840,11 @@
my $queryid=&reply("querysend:".$query.':'.$udom.':'.$uname.':'.$command,
$uhome);
unless ($queryid=~/^$uhost\_/) { return 'error: '.$queryid; }
+ return get_query_reply($queryid);
+}
+
+sub get_query_reply {
+ my $queryid=shift;
my $replyfile=$perlvar{'lonDaemons'}.'/tmp/'.$queryid;
my $reply='';
for (1..100) {
@@ -1849,10 +1854,10 @@
$reply.=<$fh>;
$fh->close;
} else { return 'error: reply_file_error'; }
- }
- return &unescape($reply);
+ return &unescape($reply);
+ }
}
- return 'error: timeout';
+ return 'timeout:'.$queryid;
}
sub courselog_query {
@@ -2689,10 +2694,15 @@
sub symbread {
my $thisfn=shift;
+# no filename provided? try from environment
unless ($thisfn) {
if ($ENV{'request.symb'}) { return &symbclean($ENV{'request.symb'}); }
$thisfn=$ENV{'request.filename'};
}
+# is that filename actually a symb? Verify, clean, and return
+ if ($thisfn=~/\_\_\_\d+\_\_\_(.*)$/) {
+ if (&symbverify($thisfn,$1)) { return &symbclean($thisfn); }
+ }
$thisfn=declutter($thisfn);
my %hash;
my %bighash;
@@ -2720,6 +2730,10 @@
my $ids=$bighash{'ids_/res/'.$thisfn};
unless ($ids) {
$ids=$bighash{'ids_/'.$thisfn};
+ }
+ unless ($ids) {
+# alias?
+ $ids=$bighash{'mapalias_'.$thisfn};
}
if ($ids) {
# ------------------------------------------------------------------- Has ID(s)