[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet Spreadsheet.pm

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 12 Sep 2003 18:59:48 -0000


matthew		Fri Sep 12 14:59:48 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm 
  Log:
  All sheets use the same safe space.  Tested, seems to work in basic cases.
  Requires more testing.
  
  
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.24 loncom/interface/spreadsheet/Spreadsheet.pm:1.25
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.24	Mon Sep  8 16:32:22 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Fri Sep 12 14:59:48 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.24 2003/09/08 20:32:22 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.25 2003/09/12 18:59:48 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -299,18 +299,23 @@
 =cut
 
 ######################################################
+{ 
+
+    my $safeeval;
+
 sub initialize_safe_space {
-    my $self = shift;
-    my $safeeval = new Safe(shift);
-    my $safehole = new Safe::Hole;
-    $safeeval->permit("entereval");
-    $safeeval->permit(":base_math");
-    $safeeval->permit("sort");
-    $safeeval->deny(":base_io");
-    $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
-    $safehole->wrap(\&mask,$safeeval,'&mask');
-    $safeeval->share('$@');
-    my $code=<<'ENDDEFS';
+  my $self = shift;
+  if (! defined($safeeval)) {
+      $safeeval = new Safe(shift);
+      my $safehole = new Safe::Hole;
+      $safeeval->permit("entereval");
+      $safeeval->permit(":base_math");
+      $safeeval->permit("sort");
+      $safeeval->deny(":base_io");
+      $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
+      $safehole->wrap(\&mask,$safeeval,'&mask');
+      $safeeval->share('$@');
+      my $code=<<'ENDDEFS';
 # ---------------------------------------------------- Inside of the safe space
 #
 # f: formulas
@@ -677,7 +682,8 @@
 
 # ------------------------------------------- End of "Inside of the safe space"
 ENDDEFS
-    $safeeval->reval($code);
+        $safeeval->reval($code);
+    }
     $self->{'safe'} = $safeeval;
     $self->{'root'} = $self->{'safe'}->root();
     #
@@ -691,6 +697,9 @@
     $self->{'safe'}->reval($initstring);
     return $self;
 }
+
+}
+
 ######################################################
 
 =pod