diff options
| author | fukachan <fukachan> | 2001-02-28 14:09:16 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-02-28 14:09:16 +0000 |
| commit | 392d0cbdb596fe4fd645bed33cd564a5a3d6026f (patch) | |
| tree | d05ebafe64746747badbbadef4d77ab78c840257 /fml/lib/FML/CGI/TicketSystem.pm | |
| parent | 72b305f51235e05ccdcbf384f54b520ed52fb969 (diff) | |
| download | fml8-392d0cbdb596fe4fd645bed33cd564a5a3d6026f.tar.gz fml8-392d0cbdb596fe4fd645bed33cd564a5a3d6026f.tar.bz2 fml8-392d0cbdb596fe4fd645bed33cd564a5a3d6026f.zip | |
dynamic load $ticket_model
Diffstat (limited to 'fml/lib/FML/CGI/TicketSystem.pm')
| -rw-r--r-- | fml/lib/FML/CGI/TicketSystem.pm | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/fml/lib/FML/CGI/TicketSystem.pm b/fml/lib/FML/CGI/TicketSystem.pm index 3ea72889..9e17b847 100644 --- a/fml/lib/FML/CGI/TicketSystem.pm +++ b/fml/lib/FML/CGI/TicketSystem.pm @@ -12,6 +12,11 @@ package FML::CGI::TicketSystem; use strict; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; +use CGI qw/:standard/; # load standard CGI routines +use FML::Process::CGI; + +@ISA = qw(FML::Process::CGI Exporter); + =head1 NAME @@ -33,33 +38,63 @@ C<FML::CGI::TicketSystem> is a subclass of C<FML::Process::CGI>. =head1 METHODS -=cut - -use CGI qw/:standard/; # load standard CGI routines -use FML::Process::CGI; - -@ISA = qw(FML::Process::CGI Exporter); - +Almost methods are forwarded to C<FML::Process::CGI> base class. =head2 C<run()> +main method. + =cut # See CGI.pm for more details sub run { - my ($curproc) = @_; + my ($curproc, $args) = @_; + my $ticket = $curproc->_load_ticket_model_module($args); + + print start_html('ticket system interface'), "\n"; - print start_html('hello world'), "\n"; print "<PRE>\n"; - print " hen hen hen \n"; + + my $argv = $args->{ ARGV }; + $argv->[ 0 ] = 'list'; + $ticket->show_summary($curproc, $args); + print "</PRE>\n"; + + print "\n"; print end_html; print "\n"; } +sub _load_ticket_model_module +{ + my ($curproc, $args) = @_; + my $config = $curproc->{ config }; + my $model = $config->{ ticket_model }; + my $pkg = "FML::Ticket::Model::"; + + if ($model eq 'toymodel') { + $pkg .= $model; + } + else { + Log("ticket: unknown model"); + return; + } + + # fake use() to do "use FML::Ticket::$model;" + eval qq{ require $pkg; $pkg->import();}; + unless ($@) { + return $pkg->new($curproc, $args); + } + else { + Log($@); + } +} + + =head1 SEE ALSO L<CGI>, |
