[Jifty-commit] r4107 - in jifty/branches/virtual-models: . lib/Jifty/View/Declare

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Sep 13 11:35:13 EDT 2007


Author: sterling
Date: Thu Sep 13 11:35:12 2007
New Revision: 4107

Modified:
   jifty/branches/virtual-models/   (props changed)
   jifty/branches/virtual-models/lib/Jifty/Script/Schema.pm
   jifty/branches/virtual-models/lib/Jifty/View/Declare/Page.pm

Log:
 r12059 at dynpc145:  andrew | 2007-09-13 10:34:44 -0500
 Merge down from trunk.
  r12048 at dynpc145:  andrew | 2007-09-12 21:21:59 -0500
  Fixing a typo in the plugin DB version metadata key affecting upgrades.
  r12049 at dynpc145:  andrew | 2007-09-12 22:19:16 -0500
  Improving schema setup for plugins that are turned on after the application is initially deployed.
  r12057 at dynpc145:  andrew | 2007-09-13 10:22:35 -0500
  Removing the display style from the jifty-result-popup, which is breaking it.
 


Modified: jifty/branches/virtual-models/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Script/Schema.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/Script/Schema.pm	Thu Sep 13 11:35:12 2007
@@ -199,7 +199,7 @@
         for my $plugin (Jifty->plugins) {
             my $plugin_bootstrapper = $plugin->bootstrapper;
             Jifty::Util->require($plugin_bootstrapper);
-            $plugin_bootstrapper->run() if $bootstrapper->can('run');
+            $plugin_bootstrapper->run() if $plugin_bootstrapper->can('run');
         }
     };
     die $@ if $@;
@@ -344,14 +344,50 @@
 
     for my $plugin (Jifty->plugins) {
         my $plugin_class = ref $plugin;
-        my $dbv  = version->new( Jifty::Model::Metadata->load($plugin_class . '_version') || '0.0.0' );
+
+        my $dbv  = Jifty::Model::Metadata->load($plugin_class . '_db_version');
         my $appv = version->new( $plugin->version );
 
-        next unless $self->upgrade_tables( $plugin_class, $dbv, $appv, $plugin->upgrade_class );
-        if ( $self->{print} ) {
-            warn "Need to upgrade ${plugin_class}_db_version to $appv here!";
-        } else {
-            Jifty::Model::Metadata->store( $plugin_class . '_db_version' => $appv );
+        # Upgrade this plugin from dbv -> appv
+        if (defined $dbv) {
+            $dbv = version->new( $dbv );
+
+            next unless $self->upgrade_tables( $plugin_class, $dbv, $appv, $plugin->upgrade_class );
+            if ( $self->{print} ) {
+                warn "Need to upgrade ${plugin_class}_db_version to $appv here!";
+            } else {
+                Jifty::Model::Metadata->store( $plugin_class . '_db_version' => $appv );
+            }
+        }
+
+        # Install this plugin
+        else {
+            my $log = Log::Log4perl->get_logger("SchemaTool");
+            $log->info("Generating SQL to set up $plugin_class...");
+            Jifty->handle->begin_transaction;
+
+            # Create the tables
+            $self->create_tables_for_models(
+                grep { $_->isa('Jifty::DBI::Record') and /^\Q$plugin_class\E::Model::/ }
+                     $self->schema->models);
+            
+            # Save the plugin version to the database
+            Jifty::Model::Metadata->store( $plugin_class . '_db_version' => $appv )
+                unless $self->{print};
+
+            # Run the bootstrapper for initial data
+            unless ($self->{print}) {
+                eval {
+                    my $bootstrapper = $plugin->bootstrapper;
+                    Jifty::Util->require($bootstrapper);
+                    $bootstrapper->run if $bootstrapper->can('run');
+                };
+                die $@ if $@;
+            }
+                
+            # Save them records
+            Jifty->handle->commit;
+            $log->info("Set up $plugin_class version $appv");
         }
     }
 }

Modified: jifty/branches/virtual-models/lib/Jifty/View/Declare/Page.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/View/Declare/Page.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/View/Declare/Page.pm	Thu Sep 13 11:35:12 2007
@@ -192,7 +192,7 @@
     show('/keybindings');
     with( id => "jifty-wait-message", style => "display: none" ),
         div { _('Loading...') };
-    with( id => "jifty-result-popup", style => "display: none" ),
+    with( id => "jifty-result-popup" ),
         div { };
 
     # This is required for jifty server push.  If you maintain your own


More information about the Jifty-commit mailing list