[Jifty-commit] r2722 - in jifty/branches/virtual-models: . lib/Jifty/Model

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jan 29 06:51:42 EST 2007


Author: jesse
Date: Mon Jan 29 06:51:27 2007
New Revision: 2722

Modified:
   jifty/branches/virtual-models/   (props changed)
   jifty/branches/virtual-models/lib/Jifty/Model/ModelClass.pm
   jifty/branches/virtual-models/lib/Jifty/Model/ModelClassColumn.pm
   jifty/branches/virtual-models/lib/Jifty/Script/Database.pm

Log:
 r21675 at hualien:  jesse | 2007-01-29 19:48:02 +0800
 * updating the database dump script to match audrey's new uuid desgin


Modified: jifty/branches/virtual-models/lib/Jifty/Model/ModelClass.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Model/ModelClass.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/Model/ModelClass.pm	Mon Jan 29 06:51:27 2007
@@ -26,7 +26,6 @@
 use Jifty::Record schema {
     column name => type is 'text';
     column description => type is 'text'; 
-    column uuid => type is 'text', is immutable;
     column included_columns => refers_to Jifty::Model::ModelClassColumnCollection by 'model_class';
 };
 
@@ -60,7 +59,6 @@
     my $self = shift;
     my $idref = shift;
     $self->load_by_cols(id => $$idref);
-    $self->__set(column => 'uuid', value => Jifty::Util->generate_uuid) unless ($self->__value('uuid'));
     $self->instantiate();
     $self->qualified_class->create_table_in_db();
 

Modified: jifty/branches/virtual-models/lib/Jifty/Model/ModelClassColumn.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Model/ModelClassColumn.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/Model/ModelClassColumn.pm	Mon Jan 29 06:51:27 2007
@@ -44,7 +44,6 @@
     column readable => type is 'boolean', default is 'true';
     column writable => type is 'boolean', default is 'true';
     column default_value => type is 'text';
-    column uuid => type is 'text', is immutable;
 };
 
 =head2 after_create
@@ -57,8 +56,6 @@
     my $self = shift;
     my $idref = shift;
     $self->load_by_cols(id => $$idref);
-    $self->__set(column => 'uuid', value => Jifty::Util->generate_uuid) 
-        unless ($self->__value('uuid'));
     $self->model_class->add_column($self);
 
     my $ret = Jifty->handle->simple_query( $self->model_class->qualified_class->add_column_sql( $self->name ) );

Modified: jifty/branches/virtual-models/lib/Jifty/Script/Database.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Script/Database.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/Script/Database.pm	Mon Jan 29 06:51:27 2007
@@ -102,7 +102,7 @@
     my $current_tables = Jifty::Model::ModelClassCollection->new();
     $current_tables->unlimit();
     while ( my $table = $current_tables->next ) {
-        if ( my $new_table = delete $new_tables->{ $table->uuid } ) {
+        if ( my $new_table = delete $new_tables->{ $table->__uuid } ) {
 
             # we have the same table in the db and the dump
             # let's sync its attributes from the dump then sync its columns
@@ -116,17 +116,14 @@
             my $current_columns = $table->included_columns;
             my $new_columns     = {};
             map {
-                delete
-                    $_->{id};   # the id is only important on the first system
-                $new_columns->{ $_->uuid } = $_
-                } grep {
-                $_->{model_class} = $table->{uuid}
-                } values %$columns;
+                delete $_->{id};   # the id is only important on the first system
+                $new_columns->{ $_->__uuid } = $_
+                } grep { $_->{model_class} = $table->{__uuid} } values %$columns;
 
             while ( my $column = $current_columns->next ) {
 
                 # First, update ones we know about
-                if ( my $new_column = delete $new_columns->{ $column->uuid } )
+                if ( my $new_column = delete $new_columns->{ $column->__uuid } )
                 {
                     foreach my $key ( keys %$new_column ) {
                         unless ( $column->$key() eq $new_column->{$key} ) {
@@ -171,7 +168,7 @@
         my ( $val, $msg ) = $class->create( %{$table} );
 
         # Now that we have a brand new model, let's find all its columns
-        my @cols = grep { $_->{model_class} = $table->{uuid} } values %$columns;
+        my @cols = grep { $_->{model_class} = $table->{__uuid} } values %$columns;
         foreach my $col (@cols) {
             delete $col->{id};
             Jifty::Model::ModelClassColumn->create(%$col);
@@ -201,7 +198,7 @@
                 # If it's a reference and we can get its uuid, do that
                 if ( UNIVERSAL::isa( $_->refers_to, 'Jifty::DBI::Record' ) ) {
                     my $obj = $item->_to_record( $_->name => $item->__value( $_->name ) );
-                    $value = $obj->__value('uuid') || $item->__value( $_->name );
+                    $value = $obj->id ? $obj->__uuid : $item->__value( $_->name );
 
                 } else {
 
@@ -210,8 +207,7 @@
                 next unless defined $value;
                 $ds->{ $_->name } = $value;
             }
-            $content->{$model}
-                ->{ ( $item->can('uuid') ? $item->uuid : $item->id ) } = $ds;
+            $content->{$model}->{  $item->__uuid } = $ds;
         }
 
 


More information about the Jifty-commit mailing list