From: Mike G. v. a. <we...@ma...> - 2010-06-07 20:13:13
|
Log Message: ----------- added envir method for exporting the envir (read only) simplified code in PGalias.pm Modified Files: -------------- pg/lib: PGalias.pm PGcore.pm Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.8 -r1.9 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -37,7 +37,10 @@ =head2 Utility Macros - not_null(item) returns 1 or 0 + +=head4 not_null + + not_null(item) returns 1 or 0 empty arrays, empty hashes, strings containing only whitespace are all NULL and return 0 all undefined quantities are null and return 0 @@ -57,6 +60,19 @@ } } +=head4 pretty_print + + Usage: warn pretty_print( $rh_hash_input) + TEXT(pretty_print($ans_hash)); + TEXT(pretty_print(~~%envir )); + +This can be very useful for printing out HTML messages about objects while debugging + +=cut + +# ^function pretty_print +# ^uses lex_sort +# ^uses pretty_print sub pretty_print { # provides html output -- NOT a method my $r_input = shift; my $level = shift; @@ -289,7 +305,22 @@ $self->{OUTPUT_ARRAY}; } +sub envir { + my $self = shift; + my $in_key = shift; + if ( not_null($in_key) ) { + if (defined ($self->{envir}->{$in_key} ) ) { + warn "result is", $self->{envir}->{$in_key}; + } else { + warn "\$envir{$in_key} is not defined"; + return ''; + } + } else { + warn "<h3> Environment</h3>".pretty_print($self->{envir}); + return ''; + } +} =item LABELED_ANS() TEXT(labeled_ans_rule("name1"), labeled_ans_rule("name2")); Index: PGalias.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGalias.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/PGalias.pm -Llib/PGalias.pm -u -r1.7 -r1.8 --- lib/PGalias.pm +++ lib/PGalias.pm @@ -760,17 +760,17 @@ my $self = shift; my $fileName = shift; # probably the name of a jar file #check cache first - return $appletCodebaseLocations{$fileName} - if defined($appletCodebaseLocations{$fileName}) - and $appletCodebaseLocations{$fileName} =~/\S/; + if (defined($appletCodebaseLocations{$fileName}) + and $appletCodebaseLocations{$fileName} =~/\S/ ){ + $appletCodebaseLocations{$fileName} + + + } my $appletPath = $self->{appletPath}; foreach my $appletLocation (@{$appletPath}) { if ($appletLocation =~ m|^/|) { $appletLocation = "$server_root_url$appletLocation"; } - return $appletLocation; # --hack workaround -- just pick the first location and use that -- no checks -# hack to workaround conflict between lwp-request and apache2 -# comment out the check_url block my $url = "$appletLocation/$fileName"; if ($self->check_url($url)) { $appletCodebaseLocations{$fileName} = $appletLocation; #update cache |