Quoting Jesse Erlbaum <suppressed>:
> Hi All --
>
> I have a little module I've been working on, and I'd love to get some
> feedback. You can download it here:
I finally found some time to look at your new module... It looks very
interesting. I definately think it will be useful to people. I particularly
like how easy it is to customize this to your own style of coding.
One comment I have on the code it generates. I personally don't like the fact
that the Database connection is made on every call. I quite often have a mix of
pages that may or may not require the database. I realize that I could easily
customize the app_module.tmpl template locally for my own use, but I think it is
at least worth bringing up. Personally I would use something simple like the
following for database access.
sub dbh {
my $self = shift;
unless ($self->{_dbh}) {
# First call to this function so connect to the DB
$self->{_dbh} = <tmpl_var new_dbh_method>;
or die "Can't connect to database";
}
return $self->{_dbh};
}
Then in the code you can copy the database handle to your function by using:
my $dbh = $self->dbh;
or use it directly:
my $sth = $self->dbh->prepare(...);
The teardown function could still be used to disconnect the database if a
connection was opened. I realize that everyone has their own coding styles, so
feel free to ignore this if you prefer your method ;)
One more thing. I use mod_perl for most of my perl applications, and think it
would be useful to have your code generator automatically add a mod_perl Content
Handler function if the user wants one. I have included a simple patch that
adds a mod_perl_handler option to C::A::T which will generate the proper handler
subroutine for you. Let me know if you think it useful.
Cheers,
Cees
>
> http://www.erlbaum.net/CGI-Application-Template-0.01.tar.gz
>
>
> I made this to simplify the start-up process of making a new
> CGI::Application-based module. If you can, try it out and give me some
> feedback. In particular, I'm interested in a couple things:
>
> 1. Does it work? (Any bugs?)
> 2. Is it useful? Could you use this in your work?
> 3. Can the interface be improved?
>
>
> Here's an excerpt from the POD:
>
> ----START----->
> NAME
> CGI::Application::Template - Dynamically build
> CGI::Application modules
>
> SYNOPSIS
> use CGI::Application::Template;
>
> # Required methods
> my $cat = CGI::Application::Template->new();
> $cat->package_name('My::Widget::Browser');
> $cat->start_mode('list_widgets');
> $cat->run_modes(qw/
> list_widgets
> add_widget
> insert_widget
> edit_widget
> update_widget
> delete_widget
> /);
>
> # Optional methods
> $cat->base_module('My::CGI::Application');
> $cat->use_modules(qw/My::DBICreds My::Utilities/);
> $cat->new_dbh_method('My::DBICreds->new_dbh()');
> $cat->tmpl_path('Path/To/My/Templates/');
>
> # Output-related methods
> $cat->app_module_tmpl('my_standard_cgiapp.tmpl');
> $cat->output_app_module();
>
> DESCRIPTION
> CGI::Application::Template provides a means by which a
> CGI::Application module can be created from code, as
> opposed to being written by hand. The goal of this module
> is two-fold:
>
> 1. To ease the creation of new CGI::Application modules.
> 2. To allow standardization of CGI::Application coding
> styles to be more uniformly applied.
> <----END----
>
>
>
> Thanks!
>
> -Jesse-
>
>
>
> --
>
> Jesse Erlbaum
> The Erlbaum Group
> suppressed
> Phone: 212-684-6161
> Fax: 212-684-6226
>
>
>
>
> ---------------------------------------------------------------------
> Web Archive: http://www.mail-archive.com/suppressed/
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
>
>
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/suppressed/ To unsubscribe, e-mail: suppressed For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.