# BEGIN BPS TAGGED BLOCK {{{
#
# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+#
+# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
}
-use lib ( "@LOCAL_LIB_PATH@", "@RT_LIB_PATH@" );
+# fix lib paths, some may be relative
+BEGIN {
+ require File::Spec;
+ my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
+ my $bin_path;
+
+ for my $lib (@libs) {
+ unless ( File::Spec->file_name_is_absolute($lib) ) {
+ unless ($bin_path) {
+ if ( File::Spec->file_name_is_absolute(__FILE__) ) {
+ $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
+ }
+ else {
+ require FindBin;
+ no warnings "once";
+ $bin_path = $FindBin::Bin;
+ }
+ }
+ $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
+ }
+ unshift @INC, $lib;
+ }
+
+}
use RT;
package RT::Mason;
#This drags in RT's config.pm
BEGIN {
RT::LoadConfig();
- if ($RT::DevelMode) { require Module::Refresh; }
+ if (RT->Config->Get('DevelMode')) { require Module::Refresh; }
+ RT->InitPluginPaths();
}
-
{
+ require RT::Handle;
+ my $dsn = RT::Handle->DSN;
+ my $user = RT->Config->Get('DatabaseUser');
+ my $pass = RT->Config->Get('DatabasePassword');
+
+ my $dbh = DBI->connect(
+ $dsn, $user, $pass,
+ { RaiseError => 0, PrintError => 0 },
+ );
+ if ( $dbh ) {
+ my ($status, $msg) = RT::Handle->CheckCompatibility( $dbh, 'post' );
+ die $msg unless $status;
+ }
+}
+{
package HTML::Mason::Commands;
use vars qw(%session);
}
use RT::Interface::Web;
use RT::Interface::Web::Handler;
-$Handler = RT::Interface::Web::Handler->new(@RT::MasonParameters);
-if ($ENV{'MOD_PERL'} && !$RT::DevelMode) {
+if ($ENV{'MOD_PERL'} && !RT->Config->Get('DevelMode')) {
# Under static_source, we need to purge the component cache
# each time we restart, so newer components may be reloaded.
#
use File::Path qw( rmtree );
use File::Glob qw( bsd_glob );
- rmtree([ bsd_glob("$RT::MasonDataDir/obj/*") ], 0, 1);
+ my @files = bsd_glob("$RT::MasonDataDir/obj/*");
+ rmtree([ @files ], 0, 1) if @files;
}
sub handler {
local $SIG{__WARN__};
local $SIG{__DIE__};
- # We don't need to handle non-text, non-xml items
if ($r->content_type =~ m/^httpd\b.*\bdirectory/i) {
use File::Spec::Unix;
# Our DirectoryIndex is always index.html, regardless of httpd settings
$r->filename( File::Spec::Unix->catfile( $r->filename, 'index.html' ) );
}
- elsif (defined( $r->content_type )) {
- $r->content_type =~ m!(^text/|\bxml\b)!i or return -1;
- }
+# elsif (defined( $r->content_type )) {
+ #$r->content_type !~ m!(^text/|\bxml\b)!i or return -1;
+# }
- Module::Refresh->refresh if $RT::DevelMode;
+ Module::Refresh->refresh if RT->Config->Get('DevelMode');
RT::Init();
+ $Handler ||= RT::Interface::Web::Handler->new(
+ RT->Config->Get('MasonParameters')
+ );
+
my %session;
my $status;
eval { $status = $Handler->handle_request($r) };