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

Diff of /FigKernelPackages/FIG_CGI.pm

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

revision 1.3, Mon Dec 5 19:06:30 2005 UTC revision 1.4, Fri Jul 28 02:00:32 2006 UTC
# Line 16  Line 16 
16  #  #
17    
18    
19  #  =head1 FIG CGI Script Utility Module
20  # FIG CGI script utility module.  
21  #  This package contains utility methods for initializing and debugging CGI scripts
22    in the FIG framework.
23    
24    =cut
25    
26  package FIG_CGI;  package FIG_CGI;
27    
28        require Exporter;
29        @ISA = ('Exporter');
30        @EXPORT = qw(is_sprout);
31    
32    =head2 Public Methods
33    
34    =cut
35    
36  use strict;  use strict;
37  use FIG;  use FIG;
# Line 41  Line 51 
51  (when we are in SEED mode), or a SFXlate object (when we are in Sprout mode).  (when we are in SEED mode), or a SFXlate object (when we are in Sprout mode).
52    
53  =over4  =over4
54    
55  =item debug_save  =item debug_save
56    
57  Set this flag to true if the script should save its parameters to a  Set this flag to true if the script should save its parameters to a
58  file. (Default filename is the name of the script minus the .cgi  file. (Default filename is the name of the script minus the .cgi
59  suffix, placed in /.tmp).  suffix, placed in the /tmp/ directory).
60    
61  =item debug_load  =item debug_load
62    
# Line 57  Line 68 
68  Set this flag to true if the script should print its CGI parameters  Set this flag to true if the script should print its CGI parameters
69  before exiting.  before exiting.
70    
71    =item RETURN
72    
73    Returns a three-tuple. The first element is a FIG or Sprout object. The second
74    is a CGI object describing the environment of the calling script. The third
75    is the name of the current user.
76    
77  =back  =back
78    
79  =cut  =cut
80    
81  sub init  sub init {
82  {      # Get the parameters. The calling syntax uses parameter pairs, so we stash
83        # them in a hash.
84      my(%args) = @_;      my(%args) = @_;
85        # Get the CGI and FIG objects.
86      my $cgi = new CGI;      my $cgi = new CGI;
87      my $fig = init_fig($cgi);      my $fig = init_fig($cgi);
88        # If we're debugging, we need to know which file is to receive the debugging
89        # information.
90      my $script_name = determine_script_name();      my $script_name = determine_script_name();
91      my $file = "/tmp/${script_name}_parms";      my $file = "/tmp/${script_name}_parms";
92    
93      # warn "fig_cgi init $file\n";      # warn "fig_cgi init $file\n";
94    
95        # Check to see if we're supposed to display the parameters. Since "debug_save"
96        # mode also prints the parameters, we remember here whether or not we printed
97        # them so we don't print them twice.
98      my $printed_params;      my $printed_params;
99      if ($args{print_params})      if ($args{print_params})
100      {      {
# Line 80  Line 102 
102          $printed_params++;          $printed_params++;
103      }      }
104    
105        # Check to see if we're supposed to save the parameters to a debug file or
106        # load them from a debug file.
107      if ($args{debug_save})      if ($args{debug_save})
108      {      {
109          do_print_params($cgi) unless $printed_params;          do_print_params($cgi) unless $printed_params;
# Line 90  Line 114 
114      {      {
115          $cgi = do_debug_load($cgi, $file);          $cgi = do_debug_load($cgi, $file);
116      }      }
117        # Now the debugging stuff is done and the $cgi object looks exactly the way we
118        # want it.
119    
120      my $user = $cgi->param('user');      # Get the user's name.
121        my $user = $cgi->param('user') || "";
122    
123      return($fig, $cgi, $user);      return($fig, $cgi, $user);
124  }  }
125    
126    =head3 is_sprout
127    
128    C<< my $flag = is_sprout($object); >>
129    
130    Return TRUE if we are running in Sprout mode, else FALSE.
131    
132    =over 4
133    
134    =item object
135    
136    FIG, SFXlate, or CGI object. If a FIG object is passed in, the result is always
137    FALSE. If an SFXlate object is passed in, the result is always TRUE. If a CGI
138    object is passed in, the value of the C<SPROUT> parameter will be returned.
139    
140    =item RETURN
141    
142    Returns TRUE if we're in Sprout mode, else FALSE.
143    
144    =back
145    
146    =cut
147    
148    sub is_sprout {
149        # Get the parameters.
150        my ($object) = @_;
151        # Declare the return variable.
152        my $retVal = 0;
153        # Check the object type. Note that an unknown object or scalar will
154        # default to FALSE. This includes FIG objects, because we don't
155        # explicity check for them.
156        my $type = ref $object;
157        if ($type eq 'SFXlate') {
158            $retVal = 1;
159        } elsif ($type eq 'CGI') {
160            $retVal = $object->param('SPROUT');
161        }
162        # Return the result.
163        return $retVal;
164    }
165    
166    =head3 init_tracing
167    
168    C<< FIG_CGI::init_tracing($cgi); >>
169    
170    Set up tracing. Tracing will be
171    
172    =over 4
173    
174    TODO: items
175    
176    =back
177    
178    =cut
179    
180    sub init_tracing {
181        # Get the parameters.
182        my ($cgi) = @_;
183        # Declare the return variable.
184        my $retVal;
185        # TODO: code
186        # Return the result.
187        return $retVal;
188    }
189    
190  sub init_tracing  sub init_tracing
191  {  {
192      my($cgi) = @_;      my($cgi) = @_;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3