[Catalyst-commits] r9437 - in
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst:
Example/Controller Helper Helper/Controller
zby at dev.catalyst.perl.org
zby at dev.catalyst.perl.org
Thu Mar 5 21:18:04 GMT 2009
Author: zby
Date: 2009-03-05 21:18:04 +0000 (Thu, 05 Mar 2009)
New Revision: 9437
Modified:
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/Controller/InstantCRUD.pm
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/InstantCRUD.pm
Log:
rest
Modified: trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm 2009-03-05 21:12:54 UTC (rev 9436)
+++ trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm 2009-03-05 21:18:04 UTC (rev 9437)
@@ -28,7 +28,7 @@
sub model_item {
my ( $self, $c, @pks ) = @_;
my $rs = $self->model_resultset($c);
- my $item = scalar @pks ? $rs->find( @pks, { key => 'primary' }) : $rs->new( {} );
+ my $item = $rs->find( @pks, { key => 'primary' });
return $item;
}
@@ -102,11 +102,9 @@
sub by_id_GET : Local {
my ( $self, $c, @args ) = @_;
my @model_pks = $self->model_pks( $c );
- warn "model pks: @model_pks";
my @pks = @args[ 0 .. scalar @model_pks - 1 ];
- warn "pks: @pks";
- my $view_type = $args[ scalar @model_pks ] || 'view';
- warn "view_type: $view_type";
+ my $view_type = $args[ scalar @model_pks ];
+ $view_type = 'view' if $view_type ne 'edit';
my $item = $self->model_item( $c, @pks );
$c->stash->{item} = $item;
if( $view_type eq 'edit' ){
@@ -126,11 +124,7 @@
sub by_id_PUT : Local {
my ( $self, $c, @args ) = @_;
my @model_pks = $self->model_pks( $c );
- warn "model pks: @model_pks";
my @pks = @args[ 0 .. scalar @model_pks - 1 ];
- warn "pks: @pks";
- my $item = $self->model_item( $c, @pks );
- $c->stash->{item} = $item;
my $form_name = ref( $self ) . '::' . $self->source_name . 'Form';
my $form = $form_name->new();
$form->add_fields( 'x-tunneled-method' => { type => 'hidden', value => 'PUT' } );
@@ -140,8 +134,8 @@
$processor->init_params( $params );
my $item = $processor->dbic_from_form(@pks);
if( $item ){
- $c->res->redirect( $c->uri_for( 'view', $item->id ) );
- $c->stash( item => $item );
+ my @new_pks = map { $item->$_ } @model_pks;
+ $c->res->redirect( $c->uri_for( 'by_id', @new_pks ) );
}
else{
$c->stash( form => $form );
Modified: trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/Controller/InstantCRUD.pm
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/Controller/InstantCRUD.pm 2009-03-05 21:12:54 UTC (rev 9436)
+++ trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/Controller/InstantCRUD.pm 2009-03-05 21:18:04 UTC (rev 9437)
@@ -51,9 +51,19 @@
=begin pod_to_ignore
__compclass__
+use strict;
+use warnings;
+
package [% class %];
use base "Catalyst::Example::Controller::InstantCRUD";
-use strict;
+__PACKAGE__->config(
+ serialize => {
+ default => 'text/html',
+ map => {
+ 'text/html' => [ 'View', 'TT' ],
+ }
+ }
+);
[% form_code %]
Modified: trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/InstantCRUD.pm
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/InstantCRUD.pm 2009-03-05 21:12:54 UTC (rev 9436)
+++ trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Helper/InstantCRUD.pm 2009-03-05 21:18:04 UTC (rev 9437)
@@ -42,6 +42,7 @@
use warnings;
use Catalyst::Runtime '5.70';
+use Catalyst::Request::REST::ForBrowsers;
use Catalyst qw/
-Debug
@@ -62,6 +63,7 @@
our $VERSION = '0.01';
__PACKAGE__->config( name => '[% name %]' );
+__PACKAGE__->request_class( 'Catalyst::Request::REST::ForBrowsers' );
# Start the application
__PACKAGE__->setup;
More information about the Catalyst-commits
mailing list