7 use FS::Mason qw( mason_interps );
11 # Bring in ApacheHandler, necessary for mod_perl integration.
12 # Uncomment the second line (and comment the first) to use
13 # Apache::Request instead of CGI.pm to parse arguments.
14 use HTML::Mason::ApacheHandler;
15 # use HTML::Mason::ApacheHandler (args_method=>'mod_perl');
17 ###use Module::Refresh;###
19 # Create Mason objects
21 my( $fs_interp, $rt_interp ) = mason_interps('apache');
23 my $ah = new HTML::Mason::ApacheHandler (
25 request_class => 'FS::Mason::Request',
26 args_method => 'CGI', #(and FS too)
29 # Activate the following if running httpd as root (the normal case).
30 # Resets ownership of all files created by Mason at startup.
32 #chown (Apache->server->uid, Apache->server->gid, $interp->files_written);
41 #from rt/bin/webmux.pl(.in)
42 if ( !$protect_fds && $ENV{'MOD_PERL'} && exists $ENV{'MOD_PERL_API_VERSION'}
43 && $ENV{'MOD_PERL_API_VERSION'} >= 2
45 # under mod_perl2, STDIN and STDOUT get closed and re-opened,
46 # however they are not on FD 0 and 1. In this case, the next
47 # socket that gets opened will occupy one of these FDs, and make
48 # all system() and open "|-" calls dangerous; for example, the
49 # DBI handle can get this FD, which later system() calls will
50 # close by putting garbage into the socket.
52 push @{$protect_fds}, IO::Handle->new_from_fd(0, "r")
53 if fileno(STDIN) != 0;
54 push @{$protect_fds}, IO::Handle->new_from_fd(1, "w")
55 if fileno(STDOUT) != 1;
58 # If you plan to intermix images in the same directory as
59 # components, activate the following to prevent Mason from
60 # evaluating image files as components.
62 #return -1 if $r->content_type && $r->content_type !~ m|^text/|i;
64 ###Module::Refresh->refresh;###
66 $r->content_type('text/html; charset=utf-8');
67 #$r->content_type('text/html; charset=iso-8859-1');
70 my $headers = $r->headers_out;
71 $headers->{'Cache-control'} = 'no-cache';
73 $headers->{'Expires'} = '0';
75 # $r->send_http_header;
77 if ( $r->filename =~ /\/rt\// ) { #RT
79 # We don't need to handle non-text, non-xml items
80 return -1 if defined( $r->content_type )
81 && $r->content_type !~ m!(^text/|\bxml\b)!io;
89 $ah->interp($rt_interp);
98 #we don't want the RT error handlers under FS
100 no warnings 'uninitialized';
101 undef($SIG{__WARN__}) if defined($SIG{__WARN__});
102 undef($SIG{__DIE__}) if defined($SIG{__DIE__} );
105 $ah->interp($fs_interp);
111 eval { $status = $ah->handle_request($r); };
114 # $RT::Logger->crit($@);
121 # if ($RT::Handle->TransactionDepth) {
122 # $RT::Handle->ForceRollback;
124 #"Transaction not committed. Usually indicates a software fault. Data loss may have occurred"
131 my $rt_initialized = 0;
134 return unless $RT::VERSION;
136 if ( $rt_initialized ) {
137 RT::ConnectToDatabase();
138 RT::InitSignalHandlers();