[Catalyst-commits] r8356 - in CatalystX-CRUD/CatalystX-CRUD/trunk:
. lib/CatalystX/CRUD
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Fri Sep 5 05:44:06 BST 2008
Author: karpet
Date: 2008-09-05 05:44:06 +0100 (Fri, 05 Sep 2008)
New Revision: 8356
Modified:
CatalystX-CRUD/CatalystX-CRUD/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/REST.pm
Log:
check for $c->res->location before redirecting in postcommit()
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/Changes 2008-09-04 19:00:57 UTC (rev 8355)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/Changes 2008-09-05 04:44:06 UTC (rev 8356)
@@ -153,5 +153,6 @@
* change behaviour of get_primary_key() in base Controller to not look in req->params for pk values.
This allows for changing the PK as part of an update.
* add new() in REST to call next::method. Works around (some) multiple inheritance issues.
+ * check for $c->res->location before redirecting in postcommit()
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm 2008-09-04 19:00:57 UTC (rev 8355)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm 2008-09-05 04:44:06 UTC (rev 8356)
@@ -798,14 +798,16 @@
sub postcommit {
my ( $self, $c, $o ) = @_;
- my $id = $self->make_primary_key_string($o);
+ unless ( defined $c->res->location and length $c->res->location ) {
+ my $id = $self->make_primary_key_string($o);
- if ( $c->action->name eq 'rm' ) {
- $c->response->redirect( $c->uri_for('') );
+ if ( $c->action->name eq 'rm' ) {
+ $c->response->redirect( $c->uri_for('') );
+ }
+ else {
+ $c->response->redirect( $c->uri_for( '', $id, 'view' ) );
+ }
}
- else {
- $c->response->redirect( $c->uri_for( '', $id, 'view' ) );
- }
1;
}
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/REST.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/REST.pm 2008-09-04 19:00:57 UTC (rev 8355)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/REST.pm 2008-09-05 04:44:06 UTC (rev 8356)
@@ -386,14 +386,18 @@
my ( $self, $c, $o ) = @_;
my $id = $self->make_primary_key_string($o);
- if ( $c->action->name eq 'rm' ) {
- $c->response->redirect( $c->uri_for('') );
+ unless ( defined $c->res->location and length $c->res->location ) {
+
+ if ( $c->action->name eq 'rm' ) {
+ $c->response->redirect( $c->uri_for('') );
+ }
+ else {
+ $c->response->redirect( $c->uri_for( '', $id ) );
+ }
+
}
- else {
- $c->response->redirect( $c->uri_for( '', $id ) );
- }
- 1;
+ $self->next::method( $c, $o );
}
=head2 new
More information about the Catalyst-commits
mailing list