[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 328 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
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 STDERR "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 "PGbasicmacros.pl", 108 "PGbasicmacros.pl",
97 "PGchoicemacros.pl", 109 "PGchoicemacros.pl",
98 "PGanswermacros.pl", 110 "PGanswermacros.pl",
99 "PGnumericalmacros.pl", 111 "PGnumericalmacros.pl",
100 "PGgraphmacros.pl", 112 "PGgraphmacros.pl",
101 "PGauxiliaryFunctions.pl", 113 "PGauxiliaryFunctions.pl",
102 "PGmatrixmacros.pl", 114 "PGmatrixmacros.pl",
103 "PGstatisticsmacros.pl",
104 "PGcomplexmacros.pl", 115 "PGcomplexmacros.pl",
116 "PGstatisticsmacros.pl"
117
105 ); 118 );
106 119
107 ENDDOCUMENT(); 120 ENDDOCUMENT();
108 121
109END_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
110 142
143
144}
145#print $INITIAL_MACRO_PACKAGES;
111############################################################################### 146###############################################################################
112# 147#
113############################################################################### 148###############################################################################
114 149
115############################################################################### 150###############################################################################
116############################################################################### 151###############################################################################
117 152
118#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";
119 154
120 155
121 156
122############################################################################### 157###############################################################################
158#
159# INITIALIZATION
160#
123# The following code initializes an instantiation of PGtranslator5 in the 161# The following code initializes an instantiation of PGtranslator5 in the
124# 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
125# children forked from this parent process by the daemon. 163# children forked from this parent process by the daemon.
126# 164#
127# 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
128# though their namespaces are the same. 166# though their namespaces are the same.
129############################################################################### 167###############################################################################
130 168
131 169print STDERR "Begin intitalization\n";
132my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory, 170my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory,
133 displayMode => $displayMode, 171 displayMode => $displayMode,
134 macroDirectory => $macroDirectory}; 172 macroDirectory => $macroDirectory,
173 cgiURL => 'foo_cgiURL'};
135my $pt = new PGtranslator5; #pt stands for problem translator; 174my $pt = new PGtranslator5; #pt stands for problem translator;
136$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory, 175$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory,
137 macroDirectory => $macroDirectory, 176 macroDirectory => $macroDirectory,
138 scriptDirectory => $scriptDirectory , 177 scriptDirectory => $scriptDirectory ,
139 templateDirectory => $templateDirectory, 178 templateDirectory => $templateDirectory,
140 tempDirectory => $Global::courseTempDirectory, 179 tempDirectory => $Global::courseTempDirectory,
141 } 180 }
142); 181);
143$pt -> evaluate_modules( @MODULE_LIST); 182$pt -> evaluate_modules( @MODULE_LIST);
144#print STDERR "Completed loading of modules, now loading extra packages\n";
145$pt -> load_extra_packages( @EXTRA_PACKAGES ); 183$pt -> load_extra_packages( @EXTRA_PACKAGES );
146#print STDERR "Completed loading of packages, now loading environment\n";
147$pt -> environment($dummy_envir); 184$pt -> environment($dummy_envir);
148#print STDERR "Completed loading environment, next initialize\n";
149$pt->initialize(); 185$pt->initialize();
150#print STDERR "Initialized. \n";
151$pt -> unrestricted_load($PG_PL ); 186my $loadErrors = $pt -> unrestricted_load($PG_PL );
187print STDERR "$loadErrors\n" if ($loadErrors);
152$pt -> unrestricted_load($DANGEROUS_MACROS_PL); 188$loadErrors = $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
189print STDERR "$loadErrors\n" if ($loadErrors);
153$pt-> set_mask(); 190$pt-> set_mask();
154# 191#
155#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";
156 196
157$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; 197$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; # change everything to unix line endings.
158$pt->source_string( $INITIAL_MACRO_PACKAGES ); 198$pt->source_string( $INITIAL_MACRO_PACKAGES );
159#print STDERR "source strings read in\n";
160$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter 199$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter
161$pt ->translate(); 200$pt ->translate();
162 201
163print STDERR "New PGtranslator object inititialization completed.\n"; 202print STDERR "New PGtranslator object inititialization completed.\n";
164################################################################################ 203################################################################################
175sub renderProblem { 214sub renderProblem {
176 my $rh = shift; 215 my $rh = shift;
177 my $beginTime = new Benchmark; 216 my $beginTime = new Benchmark;
178 $Global::WARNINGS = ""; 217 $Global::WARNINGS = "";
179 $pt->environment($rh->{envir}); 218 $pt->environment($rh->{envir});
180 #$pt->{safe_cache} = $safe_cmpt_cache; 219
220# print STDERR pretty_print_rh($rh->{envir}), "\n\n";
221
181 $pt->initialize(); 222 $pt->initialize();
182 $pt -> unrestricted_load($PG_PL); 223 $pt -> unrestricted_load($PG_PL);
183 $pt -> unrestricted_load($DANGEROUS_MACROS_PL); 224 $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
184 $pt-> set_mask(); 225 $pt-> set_mask();
185 226
306 347
307############### 348###############
308 349
309sub echo { 350sub echo {
310 my $in= shift; 351 my $in= shift;
352 print "data $in end data\n";
311 return(ref($in)); 353 return(ref($in));
312} 354}
313sub hello { 355sub hello {
314 print "Receiving request for hello world\n"; 356 print "Receiving request for hello world\n";
315 return "Hello world"; 357 return "Hello world";
328 $out .= "base64 reference " .$$rh; 370 $out .= "base64 reference " .$$rh;
329 } else { 371 } else {
330 $out = $rh; 372 $out = $rh;
331 } 373 }
332 if (defined($type) ) { 374 if (defined($type) ) {
333 $out .= "type = $type \n"; 375 $out .= " (type = $type )\n";
334 } 376 }
335 return $out; 377 return $out;
336} 378}
337 379
338#sub xmlquit { 380#sub xmlquit {
342 384
343############################################################################### 385###############################################################################
344#OTHER SERVICES 386#OTHER SERVICES
345############################################################################### 387###############################################################################
346 388
347my $PASSWORD = 'geometry'; 389
348 390
349use File::stat; 391use File::stat;
350sub readFile { 392sub readFile {
351 my $rh = shift; 393 my $rh = shift;
352 local($|)=1; 394 local($|)=1;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9