[Bio] / FigKernelPackages / ServerThing.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/ServerThing.pm

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

revision 1.5, Tue Aug 4 18:41:56 2009 UTC revision 1.6, Thu Aug 27 19:44:45 2009 UTC
# Line 29  Line 29 
29      my ($serverName, $key, $docURL) = @_;      my ($serverName, $key, $docURL) = @_;
30      # Get the CGI parameters.      # Get the CGI parameters.
31      my $cgi;      my $cgi;
32      if (! $key) {      if (! defined $key) {
33          # No tracing key, so presume we're a web service.          # No tracing key, so presume we're a web service. Check for Fast CGI.
34          $cgi = CGI->new();          if ($ENV{REQUEST_METHOD} eq '') {
35                # Here we're doing Fast CGI. In this case, the tracing key is the
36                # server name.
37                ETracing($serverName);
38                # Loop through the fast CGI requests.
39                require CGI::Fast;
40                while ($cgi = new CGI::Fast()) {
41                    RunRequest($cgi, $serverName, $docURL);
42                }
43            } else {
44                # Here we have a normal web service (non-Fast).
45                my $cgi = CGI->new();
46          # Check for a source parameter. This gets used as the tracing key.          # Check for a source parameter. This gets used as the tracing key.
47          $key = $cgi->param('source');          $key = $cgi->param('source');
48          if (! $key) {          if (! $key) {
49              # No source parameter, so do normal setup.                  # No source parameter, so do normal setup. Note we turn off
50              ETracing($cgi);                  # CGI parameter tracing.
51                    ETracing($cgi, 'noParms');
52          } else {          } else {
53              # Set up tracing using the specified key.              # Set up tracing using the specified key.
54              ETracing($key);              ETracing($key);
55              # Trace the CGI parameters.              }
56              Tracer::TraceParms($cgi);              # Run this request.
57                RunRequest($cgi, $serverName, $docURL);
58          }          }
59      } else {      } else {
60          # We're being invoked from the command line. Use the tracing          # We're being invoked from the command line. Use the tracing
# Line 50  Line 63 
63          $cgi = CGI->new($ih);          $cgi = CGI->new($ih);
64          # Set up tracing using the specified key.          # Set up tracing using the specified key.
65          ETracing($key);          ETracing($key);
66          # Trace the CGI parameters.          # Run this request.
67          Tracer::TraceParms($cgi);          RunRequest($cgi, $serverName, $docURL);
68        }
69      }      }
70    
71    
72    =head3 RunRequest
73    
74        ServerThing::RunRequest($cgi, $serverName, $docURL);
75    
76    Run a request from the specified server using the incoming CGI parameter
77    object for the parameters.
78    
79    =over 4
80    
81    =item cgi
82    
83    CGI query object containing the parameters from the web service request.
84    
85    =item serverName
86    
87    Name of the server to be used for running the request.
88    
89    =item docURL
90    
91    URL to be used for a documentation request.
92    
93    =back
94    
95    =cut
96    
97    sub RunRequest {
98        # Get the parameters.
99        my ($cgi, $serverName, $docURL) = @_;
100      Trace("Running $serverName server request.") if T(3);      Trace("Running $serverName server request.") if T(3);
101      # Is this a documentation request?      # Is this a documentation request?
102      my $module = $cgi->param('pod');      my $module = $cgi->param('pod');
# Line 109  Line 153 
153              # If we have an error, create an error document.              # If we have an error, create an error document.
154              if ($@) {              if ($@) {
155                  $document = ErrorDocument->new($function, $@);                  $document = ErrorDocument->new($function, $@);
156                  Trace("Error loadin server module: $@") if T(2);                  Trace("Error loading server module: $@") if T(2);
157              } else {              } else {
158                  # Having successfully loaded the server code, we create the object.                  # Having successfully loaded the server code, we create the object.
159                  my $serverThing = eval("$serverName" . '->new()');                  my $serverThing = eval("$serverName" . '->new()');
# Line 138  Line 182 
182      }      }
183  }  }
184    
185    
186  =head2 Utility Methods  =head2 Utility Methods
187    
188  The methods in this section are utilities of general use to the various  The methods in this section are utilities of general use to the various

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3