[system] / trunk / xmlrpc / daemon / Webwork.pm Repository:
ViewVC logotype

Diff of /trunk/xmlrpc/daemon/Webwork.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 320 Revision 386
1#!/usr/local/bin/perl -w 1#!/usr/local/bin/perl -w
2use Safe; 2
3# Copyright (C) 2001 Michael Gage 3# Copyright (C) 2001 Michael Gage
4 4
5############################################################################### 5###############################################################################
6# The initial code simply initializes variables, defines addresses 6# The initial code simply initializes variables, defines addresses
7# for directories, defines some simple subroutines responders used in debugging 7# for directories, defines some simple subroutines responders used in debugging
17 17
18#BEGIN { 18#BEGIN {
19# local $^W=0; 19# local $^W=0;
20# require '/usr/local/lib/perl5/5.6.1/Benchmark.pm'; 20# require '/usr/local/lib/perl5/5.6.1/Benchmark.pm';
21#} 21#}
22print "using the perl version of MIME::Base64\n"; 22print STDERR "using the perl version of MIME::Base64\n";
23use MIME::Base64 qw( encode_base64 decode_base64); 23use MIME::Base64 qw( encode_base64 decode_base64);
24 24
25 25
26# These libraries contain files which must at least be available, even though 26# These libraries contain files which must at least be available, even though
27# only Global.pm is actively used. 27# only Global.pm is actively used.
28 28
29use lib "/u/gage/webwork/system/lib/", "/u/gage/webwork/system/courseScripts"; 29use lib "/Users/gage/webwork/system/lib/", "/Users/gage/webwork/system/courseScripts/";
30 30
31############################################################################### 31my $WEBWORKDIRECTORY = '/Users/gage/webwork/';
32my $COURSESCRIPTSDIRECTORY = "/Users/gage/webwork/system/courseScripts/";
33my $PGTRANSLATOR = "PGtranslator5.pm";
32 34
35my $COURSETEMPDIRECTORY = '/Users/gage/Sites/rochester_problibtmp/';
36my $COURSETEMPURL = '/~gage/rochester_problibtmp';
37
38
39
40my $PASSWORD = 'geometry';
41###############################################################################
33 42
34BEGIN{ 43BEGIN{
35 my $GLOBAL_INIT = "/u/gage/webwork/system/lib/Global.pm"; 44 my $GLOBAL_INIT = "/Users/gage/webwork/system/lib/Global.pm";
36 print "Opening $GLOBAL_INIT\n"; 45 print "Opening $GLOBAL_INIT\n";
46 require "/Users/gage/webwork/system/lib/webworkConfig.pm" or croak 'webworkConfig.pm';
37 require $GLOBAL_INIT or die $GLOBAL_INIT; 47 require $GLOBAL_INIT or croak $GLOBAL_INIT;
38 import Global; 48 import Global;
39} 49}
50$Global::cgiURL='foo';
40 51
41 52
42my $PGTRANSLATOR = "/u/gage/xmlrpc/daemon/PGtranslator5.pm";
43require $PGTRANSLATOR or die "Can't open $PGTRANSLATOR"; 53require $PGTRANSLATOR or die "Can't open $PGTRANSLATOR";
44 54
45
46
47############################################################################### 55###############################################################################
48# List and address of available problemlibraries 56# List and address myof available problemlibraries
49############################################################################### 57###############################################################################
50 58
51 59
52my $libraryPath = '/u/gage/webwork/ww_prob_lib/'; 60my $libraryPath = '${WEBWORKDIRECTORY}rochester_problib/';
53 61
54my %AVAILABLE_PROBLEM_LIBRARIES = ( ww_prob_lib => '/u/gage/webwork/ww_prob_lib/', 62my %AVAILABLE_PROBLEM_LIBRARIES = ( ww_prob_lib => "${WEBWORKDIRECTORY}rochester_problib/",
55 indiana_prob_lib => '/u/gage/webwork/Indiana_prob_lib/', 63 indiana_prob_lib => "${WEBWORKDIRECTORY}Indiana_prob_lib/",
56 capaOK_lib => '/ww/webwork/courses1/capaOK/templates/', 64 capaOK_lib => '/ww/webwork/courses1/capaOK/templates/',
57 capa_lib => '/ww/webwork/courses/capa/templates/', 65 capa_lib => '/ww/webwork/courses/capa/templates/',
58 prob_lib_cvs => '/ww/webwork/courses/WW_Prob_Lib_CVS/templates/', 66 prob_lib_cvs => '/ww/webwork/courses/WW_Prob_Lib_CVS/templates/',
59 maa_100 => '/ww/webwork/courses/maa100/templates/', 67 maa_100 => '/ww/webwork/courses/maa100/templates/',
60 teitel_physics121 => '/ww/webwork/courses/teitel-phy121/templates/', 68 teitel_physics121 => '/ww/webwork/courses/teitel-phy121/templates/',
61 ); 69 );
62 70
63############################################################################### 71###############################################################################
64# Configure daemon: 72# Configure daemon:
65############################################################################### 73###############################################################################
66my $courseScriptsDirectory = '/u/gage/webwork/system/courseScripts/'; 74my $courseScriptsDirectory = $COURSESCRIPTSDIRECTORY;
67my $macroDirectory = '/ww/webwork/courses/gage_course/templates/macros/'; 75my $macroDirectory = "${courseScriptsDirectory}macros/";
68my $scriptDirectory = '/u/gage/webwork/system/scripts/'; 76my $scriptDirectory = "${WEBWORKDIRECTORY}system/scripts/";
69my $templateDirectory = '/ww/webwork/courses/gage_course/templates/'; 77my $templateDirectory = "${WEBWORKDIRECTORY}courseData/rochester_problib/";
70 78
71$Global::courseTempDirectory = '/ww/htdocs/tmp/gage_course/'; 79$Global::courseTempDirectory = $COURSETEMPDIRECTORY;
72$Global::courseTempURL = 'http://webwork-db.math.rochester.edu/tmp/gage_course/'; 80$Global::courseTempURL = $COURSETEMPURL;
73 81
74 82
75$Global::groupID = "webwork"; 83$Global::groupID = "webadmin";
76$Global::numericalGroupID = 1005; 84$Global::numericalGroupID = 1005;
77 85
78my $displayMode = 'HTML_tth'; 86my $displayMode = 'HTML_tth';
79 87
80my $PG_PL = "${courseScriptsDirectory}PG.pl"; 88my $PG_PL = "${courseScriptsDirectory}PG.pl";
81my $DANGEROUS_MACROS_PL = "${courseScriptsDirectory}dangerousMacros.pl"; 89my $DANGEROUS_MACROS_PL = "${courseScriptsDirectory}dangerousMacros.pl";
82my @MODULE_LIST = ( "Exporter", "DynaLoader", "GD", "WWPlot", "Fun", 90my @MODULE_LIST = ( "Exporter", "DynaLoader", "GD", "WWPlot", "Fun",
83 "Circle", "Label", "PGrandom", "Units", "Hermite", 91 "Circle", "Label", "PGrandom", "Units", "Hermite",
84 "List", "Match","Multiple", "Select", "AlgParser", 92 "List", "Match","Multiple", "Select", "AlgParser",
85 "AnswerHash", "Fraction", "VectorField", "Complex1", 93 "AnswerHash", "Fraction", "VectorField", "Complex1",
86 "Complex", "MatrixReal1", "Matrix","Distributions", 94 "Complex", "MatrixReal1", "Matrix","Distributions",
87 "Regression" 95 "Regression"
88 ); 96);
89my @EXTRA_PACKAGES = ( "AlgParserWithImplicitExpand", "Expr", 97my @EXTRA_PACKAGES = ( "AlgParserWithImplicitExpand", "Expr",
90 "ExprWithImplicitExpand", "AnswerEvaluator", 98 "ExprWithImplicitExpand", "AnswerEvaluator",
91# "AnswerEvaluatorMaker"
92 ); 99
100);
101
102my $INITIAL_MACRO_PACKAGES;
103unless (defined ($main::do_not_preload_macros) && $main::do_not_preload_macros == 1) {
104
93my $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT; 105 $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT;
94 DOCUMENT(); 106 DOCUMENT();
95 loadMacros( 107 loadMacros(
96 "PGcomplexmacros.pl",
97 "PGbasicmacro.pl", 108 "PGbasicmacros.pl",
98 "PGchoicemacros.pl", 109 "PGchoicemacros.pl",
99 "PGanswermacros.pl", 110 "PGanswermacros.pl",
100 "PGnumericalmacros.pl", 111 "PGnumericalmacros.pl",
101 "PGgraphmacros.pl", 112 "PGgraphmacros.pl",
102 "PGauxiliaryFunctions.pl", 113 "PGauxiliaryFunctions.pl",
103 "PGmatrixmacros.pl", 114 "PGmatrixmacros.pl",
115 "PGcomplexmacros.pl",
104 "PGstatisticsmacros.pl" 116 "PGstatisticsmacros.pl"
105 117
106 ); 118 );
107 119
108 ENDDOCUMENT(); 120 ENDDOCUMENT();
109 121
110END_OF_TEXT 122END_OF_TEXT
123} else {
124 $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT;
125 DOCUMENT();
126 loadMacros(
127 # "PGbasicmacros.pl",
128 # "PGchoicemacros.pl",
129 # "PGanswermacros.pl",
130 # "PGnumericalmacros.pl",
131 # "PGgraphmacros.pl",
132 # "PGauxiliaryFunctions.pl",
133 # "PGmatrixmacros.pl",
134 # "PGcomplexmacros.pl",
135 # "PGstatisticsmacros.pl"
136
137 );
138
139 ENDDOCUMENT();
140
141END_OF_TEXT
111 142
143
144}
145#print $INITIAL_MACRO_PACKAGES;
112############################################################################### 146###############################################################################
113# 147#
114############################################################################### 148###############################################################################
115 149
116############################################################################### 150###############################################################################
117############################################################################### 151###############################################################################
118 152
119#print STDERR "ok so far reading file /u/gage/xmlrpc/daemon/Webwork.pm\n"; 153print STDERR "ok so far reading file ${WEBWORKDIRECTORY}xmlrpc/daemon/Webwork.pm\n";
120 154
121 155
122 156
123############################################################################### 157###############################################################################
158#
159# INITIALIZATION
160#
124# The following code initializes an instantiation of PGtranslator5 in the 161# The following code initializes an instantiation of PGtranslator5 in the
125# parent process. This initialized object is then share with each of the 162# parent process. This initialized object is then share with each of the
126# children forked from this parent process by the daemon. 163# children forked from this parent process by the daemon.
127# 164#
128# As far as I can tell, the child processes don't share any variable values even 165# As far as I can tell, the child processes don't share any variable values even
129# though their namespaces are the same. 166# though their namespaces are the same.
130############################################################################### 167###############################################################################
131 168
132 169print STDERR "Begin intitalization\n";
133my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory, 170my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory,
134 displayMode => $displayMode, 171 displayMode => $displayMode,
135 macroDirectory => $macroDirectory}; 172 macroDirectory => $macroDirectory,
173 cgiURL => 'foo_cgiURL'};
136my $pt = new PGtranslator5; #pt stands for problem translator; 174my $pt = new PGtranslator5; #pt stands for problem translator;
137$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory, 175$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory,
138 macroDirectory => $macroDirectory, 176 macroDirectory => $macroDirectory,
139 scriptDirectory => $scriptDirectory , 177 scriptDirectory => $scriptDirectory ,
140 templateDirectory => $templateDirectory, 178 templateDirectory => $templateDirectory,
141 tempDirectory => $Global::courseTempDirectory, 179 tempDirectory => $Global::courseTempDirectory,
142 } 180 }
143); 181);
144$pt -> evaluate_modules( @MODULE_LIST); 182$pt -> evaluate_modules( @MODULE_LIST);
145#print STDERR "Completed loading of modules, now loading extra packages\n";
146$pt -> load_extra_packages( @EXTRA_PACKAGES ); 183$pt -> load_extra_packages( @EXTRA_PACKAGES );
147#print STDERR "Completed loading of packages, now loading environment\n";
148$pt -> environment($dummy_envir); 184$pt -> environment($dummy_envir);
149#print STDERR "Completed loading environment, next initialize\n";
150$pt->initialize(); 185$pt->initialize();
151#print STDERR "Initialized. \n";
152$pt -> unrestricted_load($PG_PL ); 186my $loadErrors = $pt -> unrestricted_load($PG_PL );
187print STDERR "$loadErrors\n" if ($loadErrors);
153$pt -> unrestricted_load($DANGEROUS_MACROS_PL); 188$loadErrors = $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
189print STDERR "$loadErrors\n" if ($loadErrors);
154$pt-> set_mask(); 190$pt-> set_mask();
155# 191#
156#print STDERR "Unrestricted loads completed.\n"; 192# print STDERR "\nPG.pl: $PG_PL\n";
193# print STDERR "DANGEROUS_MACROS_PL: $DANGEROUS_MACROS_PL\n";
194# print STDERR "Print dummy environment\n";
195# print STDERR pretty_print_rh($dummy_envir), "\n\n";
157 196
158$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; 197$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; # change everything to unix line endings.
159$pt->source_string( $INITIAL_MACRO_PACKAGES ); 198$pt->source_string( $INITIAL_MACRO_PACKAGES );
160#print STDERR "source strings read in\n";
161$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter 199$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter
162$pt ->translate(); 200$pt ->translate();
163 201
164print STDERR "New PGtranslator object inititialization completed.\n"; 202print STDERR "New PGtranslator object inititialization completed.\n";
165################################################################################ 203################################################################################
176sub renderProblem { 214sub renderProblem {
177 my $rh = shift; 215 my $rh = shift;
178 my $beginTime = new Benchmark; 216 my $beginTime = new Benchmark;
179 $Global::WARNINGS = ""; 217 $Global::WARNINGS = "";
180 $pt->environment($rh->{envir}); 218 $pt->environment($rh->{envir});
181 #$pt->{safe_cache} = $safe_cmpt_cache; 219
220# print STDERR pretty_print_rh($rh->{envir}), "\n\n";
221
182 $pt->initialize(); 222 $pt->initialize();
183 $pt -> unrestricted_load($PG_PL); 223 $pt -> unrestricted_load($PG_PL);
184 $pt -> unrestricted_load($DANGEROUS_MACROS_PL); 224 $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
185 $pt-> set_mask(); 225 $pt-> set_mask();
186 226
307 347
308############### 348###############
309 349
310sub echo { 350sub echo {
311 my $in= shift; 351 my $in= shift;
352 print "data $in end data\n";
312 return(ref($in)); 353 return(ref($in));
313} 354}
314sub hello { 355sub hello {
315 print "Receiving request for hello world\n"; 356 print "Receiving request for hello world\n";
316 return "Hello world"; 357 return "Hello world";
329 $out .= "base64 reference " .$$rh; 370 $out .= "base64 reference " .$$rh;
330 } else { 371 } else {
331 $out = $rh; 372 $out = $rh;
332 } 373 }
333 if (defined($type) ) { 374 if (defined($type) ) {
334 $out .= "type = $type \n"; 375 $out .= " (type = $type )\n";
335 } 376 }
336 return $out; 377 return $out;
337} 378}
338 379
339#sub xmlquit { 380#sub xmlquit {
343 384
344############################################################################### 385###############################################################################
345#OTHER SERVICES 386#OTHER SERVICES
346############################################################################### 387###############################################################################
347 388
348my $PASSWORD = 'geometry'; 389
349 390
350use File::stat; 391use File::stat;
351sub readFile { 392sub readFile {
352 my $rh = shift; 393 my $rh = shift;
353 local($|)=1; 394 local($|)=1;

Legend:
Removed from v.320  
changed lines
  Added in v.386

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9