[Rt-commit] rt branch, 3.999-trunk, updated. 89f42aff429fcf2c025ae0cf10f9c8f2b3851529

clkao at bestpractical.com clkao at bestpractical.com
Thu Sep 3 14:01:50 EDT 2009


The branch, 3.999-trunk has been updated
       via  89f42aff429fcf2c025ae0cf10f9c8f2b3851529 (commit)
       via  7705494f0d4865b98c4e58592a643ee226d18929 (commit)
      from  780c5cd12a9a2e69f84a42b67551141fdba5c190 (commit)

Summary of changes:
 Makefile.PL          |    6 ++++
 lib/RT.pm            |   76 +++++++++++++++++++++----------------------------
 lib/RT/Bootstrap.pm  |    3 --
 lib/RT/Dispatcher.pm |    4 --
 lib/RT/Shredder.pm   |    1 +
 lib/RT/Test.pm       |    1 -
 6 files changed, 40 insertions(+), 51 deletions(-)

- Log -----------------------------------------------------------------
commit 7705494f0d4865b98c4e58592a643ee226d18929
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Fri Sep 4 01:51:32 2009 +0800

    add test_requires.

diff --git a/Makefile.PL b/Makefile.PL
index 1375d89..69c2150 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -44,6 +44,12 @@ requires(
     'Pod::POM'                   => 0,
 );
 
+test_requires (
+    'Test::Expect'        => 0,
+    'Test::MockTime'      => 0,
+    'String::ShellQuote'  => 0,
+);
+
 features(
 
     'Mason' => [

commit 89f42aff429fcf2c025ae0cf10f9c8f2b3851529
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Fri Sep 4 02:00:34 2009 +0800

    - remove RT::init_system_objects.
    - make RT->nobody lazily load nobody.
    - move RT initialization into RT::start, which is called at the end of
      Jifty->new.

diff --git a/lib/RT.pm b/lib/RT.pm
index 7ea5f45..a38d548 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -105,8 +105,7 @@ sub config {
 
 =head2 init
 
-L<Initilizes system objects|init_system_objects>, and L<configures
-plugins|init_plugins>.
+L<configures plugins|init_plugins>.
 
 =cut
 
@@ -116,10 +115,12 @@ sub init {
     #Get a database connection
     init_plugin_paths();
 
-    init_system_objects();
+    $System = RT::System->new();
+
     init_plugins();
     # enable approval subsystem
     require RT::Approval;
+
 }
 
 # Signal handlers
@@ -163,23 +164,6 @@ EOF
     }
 }
 
-=head2 init_system_objects
-
-Initializes system objects: C<< RT->system >>, C<< RT->system_user >>
-and C<< RT->nobody >>.
-
-=cut
-
-sub init_system_objects {
-
-    #RT's "nobody user" is a genuine database user. its ID lives here.
-    $nobody = RT::CurrentUser->new( name => 'Nobody' );
-    Carp::confess "Could not load 'Nobody' User. This usually indicates a corrupt or missing RT database"
-        unless $nobody->id;
-
-    $System = RT::System->new();
-}
-
 =head1 CLASS METHODS
 
 =head2 config
@@ -192,8 +176,7 @@ Method can be called as class method.
 
 =head2 system
 
-Returns the current system object L<RT::System>. See also
-L</init_system_objects>.
+Returns the current system object L<RT::System>.
 
 =cut
 
@@ -202,8 +185,7 @@ sub system { return RT::System->new }
 =head2 system_user
 
 Returns the system user's object, it's object of
-L<RT::CurrentUser> class that represents the system. See also
-L</init_system_objects>.
+L<RT::CurrentUser> class that represents the system.
 
 =cut
 
@@ -217,12 +199,19 @@ sub system_user {
 =head2 Nobody
 
 Returns object of Nobody. It's object of L<RT::CurrentUser> class
-that represents a user who can own ticket and nothing else. See
-also L</init_system_objects>.
+that represents a user who can own ticket and nothing else.
 
 =cut
 
-sub nobody { return $nobody }
+sub nobody {
+    unless ($nobody) {
+        $nobody = RT::CurrentUser->new( name => 'Nobody' );
+        Carp::confess "Could not load 'Nobody' User. This usually indicates a corrupt or missing RT database"
+                unless $nobody->id;
+    }
+
+    return $nobody
+}
 
 =head2 Plugins
 
@@ -319,21 +308,6 @@ nomrally, we need to do it early in BEGIN block
 sub init_jifty {
     require Jifty;
     Jifty->new;
-
-    Jifty->web->add_javascript(
-        qw( titlebox-state.js util.js ahah.js fckeditor.js list.js class.js
-        combobox.js  cascaded.js )
-    );
-
-    Jifty::Web->add_trigger(
-        name      => 'after_include_javascript',
-        callback  => sub {
-            my $webpath = RT->config->get('web_path') || '/';
-            Jifty->web->out(
-                qq{<script type="text/javascript">RT = {};RT.WebPath = '$webpath';</script>}
-            );
-        },
-    );
 }
 
 =head2 local_path
@@ -432,10 +406,26 @@ L<Jifty::DBI>
 
 =cut
 
-{
+sub start {
     #XXX TODO RT pages don't play well with Halo right now
     no warnings 'redefine';
     *Jifty::Plugin::Halo::is_proscribed = sub { 1 };
+    RT::init();
+
+    Jifty->web->add_javascript(
+        qw( titlebox-state.js util.js ahah.js fckeditor.js list.js class.js
+        combobox.js  cascaded.js )
+    );
+
+    Jifty::Web->add_trigger(
+        name      => 'after_include_javascript',
+        callback  => sub {
+            my $webpath = RT->config->get('web_path') || '/';
+            Jifty->web->out(
+                qq{<script type="text/javascript">RT = {};RT.WebPath = '$webpath';</script>}
+            );
+        },
+    );
 }
 
 1;
diff --git a/lib/RT/Bootstrap.pm b/lib/RT/Bootstrap.pm
index 9604fbb..db71f33 100644
--- a/lib/RT/Bootstrap.pm
+++ b/lib/RT/Bootstrap.pm
@@ -177,9 +177,6 @@ sub insert_initial_data {
         }
     }
 
-    # rerun to get init Nobody as well
-    RT::init_system_objects();
-
     # system role groups
     foreach my $name (qw(owner requestor cc admin_cc)) {
         my $group = RT::Model::Group->new( current_user => RT->system_user );
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index c9109b9..475e4c8 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -57,10 +57,6 @@ use RT::Interface::Web;
 use RT::Interface::Web::Handler;
 
 before qr/.*/ => run {
-    RT::init_system_objects();
-};
-
-before qr/.*/ => run {
     if ( int RT->config->get('auto_logoff') ) {
         my $now = int( time / 60 );
 
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index a89de73..59829a5 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -263,6 +263,7 @@ our %opt = ();
 
 sub init {
     %opt = @_;
+    # XXX: this shouldn't be necessary anymore, as RT.pm does init and config is lazily loaded.
     RT::load_config();
     RT::init();
 }
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 7c41a1d..427d3de 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -110,7 +110,6 @@ sub setup {
     $self->SUPER::setup($args);
 
     $self->_setup_config(@$args);
-    RT::init_system_objects();
     RT::init();
 }
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list