I spent all day yesterday trying to get some decent CRUD running. I tried some projects again (HTML::FormFu) which again failed (HTML::FormFu) and as much as I'm sure it can work generally, it isn't flexible enough for the situation I needed it to.
I started working on a module, MyApp::CRUD, for my Catalyst application. Basically It's a Moose module that has the definitions of the main id and the table. The module has 5 methods:
Now I'm able to use the API as such:
BEGIN {
use Moose;
extends 'Catalyst::Controller';
}
has 'crud' => (
is => 'rw',
isa => 'MyApp::CRUD',
lazy => 1,
default => sub {
MyApp::CRUD->new(
id => 'data_id',
table => 'Sections',
)
},
);
sub add : Local {
my ( $self, $c ) = @_;
my $id = $self->crud
->start($c)
->create('sections/add');
if ( defined $id ) {
$c->res->redirect("/sections/view/$id");
$c->detach();
}
$c->stash->{'template'} = 'sections/add.tt2';
}
sub delete : Local {
my ( $self, $c, $id ) = @_;
$self->crud
->start($c)
->delete($id);
$c->res->redirect('/sections/view');
$c->detach;
}
sub view : Local {
my ( $self, $c, $id ) = @_;
$self->crud
->start($c)
->read($id);
$c->stash->{'template'} = 'sections/view.tt2';
}
#... and so on
All in all, it didn't take too much to write and I spent most of the time trying to make modules do what I want them to do, and what they are suppose to do and not why they are doing.
It's like I'm 14 years old again and I'm trying to fix my uncle's busted old computer. Shitty hardware but you have to make due, right? I use Perl because I DON'T LIKE TO MAKE DUE.
(... for a while)
InstantCRUD (Score:1)
Re: (Score:1)
I'll check it out, thanks!
Re: (Score:1)
Re: (Score:1)
I've checked the links.
I think our biggest problem is that we're unable to define a clear cut API to CRUD. I think it would be very difficult to do this even if we decide to do it since some technologies take over that part altogether. For example, when using AJAX, you go over the rendering through the Javascript, so you have to convert portions of the rendering to Javascript (using Jemplate or ExtJS or whatnot).
Another such situation exists generally with templates, in the fact that they do the rendering i
Re: (Score:1)
Re: (Score:1)
AJAX is worthless if applied as a complete CRUD solution instead of a layer of Read in CRUD or fetching information back to the layer of form handling, such as JSON is worthless if applied as the onetime solution for CRUD instead of as a layer of data representation within a certain (or multiple) views.
Basically, you should be able to say "I want to use AJAX (ExtJS, Dojo, JQuery) as the front end for a CRUD system and represent the data in JSON. Oh wait, I actually want to not use AJAX for this specific tab
Re: (Score:1)