[Catalyst-commits] r8279 - in CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk: . lib/CatalystX/CRUD/Controller

karpet at dev.catalyst.perl.org karpet at dev.catalyst.perl.org
Mon Aug 25 04:25:15 BST 2008


Author: karpet
Date: 2008-08-25 04:25:15 +0100 (Mon, 25 Aug 2008)
New Revision: 8279

Modified:
   CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
   CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm
Log:
0.15 release

Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes	2008-08-24 19:32:34 UTC (rev 8278)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/Changes	2008-08-25 03:25:15 UTC (rev 8279)
@@ -56,4 +56,6 @@
 0.14    11 Aug 2008
         * fix Makefile.PL to reflect CXCRUD 0.28 required
 
+0.15    24 Aug 2008
+        * fix the form_to_object() method to work with 0.29 core REST api
  

Modified: CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm	2008-08-24 19:32:34 UTC (rev 8278)
+++ CatalystX-CRUD/CatalystX-CRUD-Controller-RHTMLO/trunk/lib/CatalystX/CRUD/Controller/RHTMLO.pm	2008-08-25 03:25:15 UTC (rev 8279)
@@ -4,7 +4,7 @@
 use Carp;
 use Class::C3;
 
-our $VERSION = '0.14';
+our $VERSION = '0.15';
 
 =head1 NAME
 
@@ -71,7 +71,9 @@
     my ( $self, $c ) = @_;
     $self->{_form} ||= $self->form_class->new( app => $c );
     $self->{_form}->app($c) unless defined $self->{_form}->app;
-    $self->{_form}->clear unless $self->{_form}->app->stash->{_form_called}->{ $self->action_namespace }++;
+    $self->{_form}->clear
+        unless $self->{_form}->app->stash->{_form_called}
+            ->{ $self->action_namespace }++;
     return $self->{_form};
 }
 
@@ -82,7 +84,7 @@
 =cut
 
 sub field_names {
-    my ($self, $c) = @_;
+    my ( $self, $c ) = @_;
     $self->throw_error("context required") unless defined $c;
     return $self->form($c)->field_names;
 }
@@ -116,7 +118,7 @@
     my $obj       = $c->stash->{object};
     my $obj_meth  = $self->init_object;
     my $form_meth = $self->init_form;
-    
+
     # id always comes from url but not necessarily from form
     my $id = $c->stash->{object_id};
     my %pk = $self->get_primary_key( $c, $id );
@@ -160,12 +162,14 @@
 
     # let serial column work its magic
     # if this is a first-time save (create)
-    if ( scalar( keys %pk ) == 1 or $id eq '0' ) {
-        my ( $field, $value ) = each %pk;
-        $obj->$field(undef)
-            if ( !$obj->$field || $obj->$field eq '0' || $value eq '0' );
+    #carp "serial column magic. id = $id. pk = " . Data::Dump::dump \%pk;
+    my $pk_method = $self->primary_key;
+    if ( !$id and !ref($pk_method) ) {
+        $obj->$pk_method(undef) if ( defined $obj->$pk_method );
     }
 
+    #Data::Dump::dump $obj;
+
     return $obj;
 }
 




More information about the Catalyst-commits mailing list