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

www lon-capa-cvs@mail.lon-capa.org
Sun, 05 May 2002 01:59:42 -0000


www		Sat May  4 21:59:42 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  First attempt to move towards "version-free" symb. Might be extremely broken
  and needs to be tested.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.209 loncom/lonnet/perl/lonnet.pm:1.210
--- loncom/lonnet/perl/lonnet.pm:1.209	Fri Apr 26 14:49:09 2002
+++ loncom/lonnet/perl/lonnet.pm	Sat May  4 21:59:42 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.209 2002/04/26 18:49:09 matthew Exp $
+# $Id: lonnet.pm,v 1.210 2002/05/05 01:59:42 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2507,7 +2507,7 @@
         if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db',
                       &GDBM_WRCREAT,0640)) {
 	    foreach (keys %newhash) {
-                $hash{declutter($_)}=$mapname.'___'.$newhash{$_};
+                $hash{declutter($_)}=&symbclean($mapname.'___'.$newhash{$_});
             }
             if (untie(%hash)) {
 		return 'ok';
@@ -2517,12 +2517,23 @@
     return 'error';
 }
 
+# --------------------------------------------------------------- Clean-up symb
+
+sub symbclean {
+    my $symb=shift;
+# remove version from map
+    $symb=~s/\.(\d+)\.(\w+)\_\_\_/\.$2\_\_\_/;
+# remove version from URL
+    $symb=~s/\.(\d+)\.(\w+)$/\.$2/;
+    return $symb;
+}
+
 # ------------------------------------------------------ Return symb list entry
 
 sub symbread {
     my $thisfn=shift;
     unless ($thisfn) {
-        if ($ENV{'request.symb'}) { return $ENV{'request.symb'}; }
+        if ($ENV{'request.symb'}) { return &symbclean($ENV{'request.symb'}); }
 	$thisfn=$ENV{'request.filename'};
     }
     $thisfn=declutter($thisfn);
@@ -2581,7 +2592,7 @@
            } 
         }
         if ($syval) {
-           return $syval.'___'.$thisfn; 
+           return &symbclean($syval.'___'.$thisfn); 
         }
     }
     &appenv('request.ambiguous' => $thisfn);