Skip Menu |

This queue is for tickets about the Catalyst-Example-InstantCRUD CPAN distribution.

Report information
The Basics
Id: 46830
Status: rejected
Priority: 0/
Queue: Catalyst-Example-InstantCRUD

People
Owner: Nobody in particular
Requestors: ramoore [...] axion-it.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.0.30
Fixed in: (no value)



Subject: 2 suggestions for InstantCRUD, and one possible bug
These first two are not really bugs, just suggestions. I'm using Catalyst-Example-InstantCRUD v 0.0.30 with Catalyst 5.80004 1) In the 'destroy' sub, change the forward to a redirect, otherwise, all the links on the following list page are wrong. # $c->forward('list'); $c->response->redirect($c->uri_for('list')); 2) When pulling options from a related table in sub _options_from_resultset, it would be nice to have a way to pull in something other than the PK field. I overrode this routine and changed: while( my $related_row = $related_rs->next ){ $field->add_option( $related_row->$pk => $related_row->$pk ); } to: while( my $related_row = $related_rs->next ){ $field->add_option( $related_row->$pk => $related_row->display_name || $related_row->$pk ); } And then added an appropriate display_name method to each of my models. But, I'm sure there is a better way to generalize that idea. The third issue is a possible bug. But, I'm not sure. I'm using MySQL tables with auto_increment on the PK. When start my test server and Add an item to a table, it works perfectly the first time. But, if I try to add a second item, it fails. It seem to try to UPDATE the previous entry instead of INSERTing another new one. Here is the debug output from the first, successful "Add": SELECT me.id, me.name FROM shopping_centers me WHERE ( me.id IS NULL ): INSERT INTO shopping_centers ( id, name) VALUES ( ?, ? ): 'NULL', 'aaaa' [info] *** Request 13 (0.481/s) [23066] [Wed Jun 10 13:41:38 2009] *** [debug] Body Parameters are: .-------------------------------------+--------------------------------------. | Parameter | Value | +-------------------------------------+--------------------------------------+ | foo | Add / Edit | | id | | | name | aaaa | '-------------------------------------+--------------------------------------' [debug] "POST" request for "shoppingcenters/edit" from "76.111.124.231" [debug] Path is "shoppingcenters/edit" [debug] Found sessionid "7785eea4550ee9183f1182882b207741b673128a" in cookie [debug] Restored session "7785eea4550ee9183f1182882b207741b673128a" [debug] Redirecting to "http://rh7.axion-it.com:3000/shoppingcenters/view/19" [info] Request took 0.027832s (35.930/s) .------------------------------------------------------------+-----------. | Action | Time | +------------------------------------------------------------+-----------+ | /auto | 0.007691s | | /shoppingcenters/auto | 0.000682s | | /shoppingcenters/edit | 0.012079s | | /end | 0.000321s | '------------------------------------------------------------+-----------' SELECT me.id, me.name FROM shopping_centers me WHERE ( me.id = ? ): '19' [info] *** Request 14 (0.519/s) [23066] [Wed Jun 10 13:41:38 2009] *** [debug] "GET" request for "shoppingcenters/view/19" from "76.111.124.231" [debug] Path is "shoppingcenters/view" [debug] Arguments are "19" [debug] Found sessionid "7785eea4550ee9183f1182882b207741b673128a" in cookie [debug] Restored session "7785eea4550ee9183f1182882b207741b673128a" [debug] Rendering template "shoppingcenters/view.tt" [info] Request took 0.025501s (39.214/s) And here is the output from the second, failed "Add": SELECT me.id, me.name FROM shopping_centers me WHERE ( me.id IS NULL ): UPDATE shopping_centers SET id = ?, name = ? WHERE ( id = ? ): 'NULL', 'bbbbb', '19' uri_for called with undef argument at /usr/lib/perl5/site_perl/5.8.8/Catalyst/Example/Controller/InstantCRUD.pm line 75 Use of uninitialized value in substitution (s///) at /usr/lib/perl5/site_perl/5.8.8/Catalyst.pm line 1193. [info] *** Request 22 (0.208/s) [23066] [Wed Jun 10 13:42:57 2009] *** [debug] Body Parameters are: .-------------------------------------+--------------------------------------. | Parameter | Value | +-------------------------------------+--------------------------------------+ | foo | Add / Edit | | id | | | name | bbbbb | '-------------------------------------+--------------------------------------' [debug] "POST" request for "shoppingcenters/edit" from "76.111.124.231" [debug] Path is "shoppingcenters/edit" [debug] Found sessionid "7785eea4550ee9183f1182882b207741b673128a" in cookie [debug] Restored session "7785eea4550ee9183f1182882b207741b673128a" [debug] Redirecting to "http://rh7.axion-it.com:3000/shoppingcenters/view" [info] Request took 0.027284s (36.652/s) .------------------------------------------------------------+-----------. | Action | Time | +------------------------------------------------------------+-----------+ | /auto | 0.007753s | | /shoppingcenters/auto | 0.000578s | | /shoppingcenters/edit | 0.011791s | | /end | 0.000293s | '------------------------------------------------------------+-----------' [info] *** Request 23 (0.217/s) [23066] [Wed Jun 10 13:42:57 2009] *** [debug] "GET" request for "shoppingcenters/view" from "76.111.124.231" [debug] Path is "shoppingcenters/view" [debug] Found sessionid "7785eea4550ee9183f1182882b207741b673128a" in cookie [debug] Restored session "7785eea4550ee9183f1182882b207741b673128a" [error] Caught exception in Dw_Postings::Admin::Controller::ShoppingCenters->view "You need to pass an id at /usr/lib/perl5/site_perl/5.8.8/Catalyst/Example/Controller/InstantCRUD.pm line 87." [info] Request took 0.021008s (47.601/s) I found that if I run this app in CGI mode, so that nothing but the session, survives between calls, this problem does not occur. Thanks much for making this module, it is very helpful as a starting point.
On Wed Jun 10 14:23:22 2009, ramoore wrote: Show quoted text
> These first two are not really bugs, just suggestions. > > I'm using Catalyst-Example-InstantCRUD v 0.0.30 with Catalyst 5.80004 > > 1) In the 'destroy' sub, change the forward to a redirect, otherwise, > all the links on the following list page are wrong. > # $c->forward('list'); > $c->response->redirect($c->uri_for('list'));
Fixed in 0.034 - thanks. Ad. the lists of related rows - I'll check what can be done. For the last problem - I am now using HTML::FormHandler as the base processing module and it uses DBIx::Class::ResultSet::RecursiveUpdate for the updates. There was quite a bit or change - please check if the problem still persists. Cheers, Zbigniew.
Subject: Re: [rt.cpan.org #46830] 2 suggestions for InstantCRUD, and one possible bug
Date: Tue, 05 Jan 2010 21:07:36 -0500
To: bug-Catalyst-Example-InstantCRUD [...] rt.cpan.org
From: Randy Moore <ramoore [...] axion-it.com>
Zbigniew Lukasiak via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=46830 > > > On Wed Jun 10 14:23:22 2009, ramoore wrote: >
>> These first two are not really bugs, just suggestions. >> >> I'm using Catalyst-Example-InstantCRUD v 0.0.30 with Catalyst 5.80004 >> >> 1) In the 'destroy' sub, change the forward to a redirect, otherwise, >> all the links on the following list page are wrong. >> # $c->forward('list'); >> $c->response->redirect($c->uri_for('list')); >>
> > Fixed in 0.034 - thanks. > > Ad. the lists of related rows - I'll check what can be done. > > For the last problem - I am now using HTML::FormHandler as the base > processing module and it uses DBIx::Class::ResultSet::RecursiveUpdate > for the updates. There was quite a bit or change - please check if the > problem still persists. > > Cheers, > Zbigniew. >
Hi, I finally had a chance to try the new HTML::FormHandler based InstantCRUD. I'm liking it very much. But, I did still have the same (or very similar) problem the second time I try to add a new record to a table. I was able to work around the problem by passing a ->new() object to the form as and item when adding a new row, rather than just passing an undef row id. I do not understand why that makes a difference, but it does. Here is my revised "edit" routine: sub edit : Local { my ( $self, $c, @pks ) = @_; my $item = ( @pks ) ? $self->model_item( $c, @pks ) : $self->model_resultset($c)->new( {} ); my $form = $self->form_class->new( schema => $self->model_schema($c), params => $c->req->params, item => $item, ); if( $c->req->method eq 'POST' && $form->process() ){ my $item = $form->item; $c->res->redirect( $c->uri_for( 'view', $item->id ) ); $c->stash( item => $item ); } if( @pks ){ $form->field( 'submit' )->value( 'Update' ); } else{ $form->field( 'submit' )->value( 'Create' ); } $c->stash( form => $form->render ); } Thanks much for sharing your code. -- Randy Moore Axion Information Technologies, Inc. phone: 301-587-3300 x 511 fax: 240-744-7133 http://www.axion-it.com
Marking ticket as rejected because InstantCRUD seems to have been removed from CPAN.