Thread CGI::Application: run_modes (28 answers)
Opened by esskar at 2005-01-22 03:40

pktm
 2005-01-25 16:27
#4213 #4213
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Bei mir geht das (glaube ich):
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
# esskarcgiapp.cgi
#!/Perl/bin/perl

use strict;
use FindBin qw($Bin);
use lib($Bin);
use esskarcgiapp;

my $wapp = esskarcgiapp->new();
$wapp->run();

exit(0);


Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# sorry für das kleingeschriebene modul, ist ja nur zum testen
package esskarcgiapp;

use base 'CGI::Application';

 sub cgiapp_prerun {
       my $self = shift;
       # Perform some project-specific init behavior
       # such as to implement run mode specific
       # authorization functions.
       my %loadModules = (
           'login::form' => ['esskarcgiapp_login.pm', 'CGI.pm'],
       );
       my $found = 0;
       foreach( keys(%loadModules) ) {
           if( $_ eq $self->get_current_runmode() ){
               foreach my $module( @{$loadModules{$_}} ) {
                   # überprüfen ob es das Modul gibt und ob das Laden erfolgreich war usw.
                   require $module;
               }
               $found = 1;
               last;
           } # /if
       } # /foreach
       
 } # /cgiapp_prerun

sub setup
{
 my $self = shift;

 $self->header_props(
    -type   => 'text/html',
    -charset   => 'utf-8',
 );

 $self->mode_param('action');
 $self->start_mode('login::form');
 $self->run_modes(
    'login::form' => 'login_form',
 );
}

sub login_form {
   my $lf = new esskarcgiapp_login;
   if( $lf ){
       return "loginfoprm here";
   }else{
       return "geht nicht!?";
   }
}

1;


Code: (dl )
1
2
3
4
5
package esskarcgiapp_login;

use base esskarcgiapp;

1;


Stimmts so?
XX::YY - Module müsste man mittels 'XX/YY.pm' laden können.
mfg pktm
http://www.intergastro-service.de (mein erstes CMS :) )

View full thread CGI::Application: run_modes