in reply to Re: Breaking up a CGI::Application program
in thread Breaking up a CGI::Application program

One of the good reasons for using Class::DBI too! It keeps the database code all in one place, saves the agony of using placeholders and makes the whole thing a lot simpler.

But for your particular situation dhoss there is a plugin from Mark Stosberg, CGI::Application::Plugin::DBH which puts the database initialisation in the cgiapp_init method. It even uses lazy loading so that if it is not required within a runmode the connection to the database is not made, thus saving time and bandwidth.

samtregar also makes the very useful suggestion of using <tmpl_include ..> directives in templates, this is very useful. But don't forget to ponder the use of <tmpl_if ..> and <tmpl_unless ..> directives. Although coming dangerously close to incorporating code in the HTML, they do allow a very simple, and easily managed, method of controlling presentation of menues.

Having said all of that, CGI::Application works best in a mod_perl environment when it gets to big applications. But that's the subject of another whole thread I think.

jdtoronto

  • Comment on Re^2: Breaking up a CGI::Application program

Replies are listed 'Best First'.
Re^3: Breaking up a CGI::Application program
by stonecolddevin (Parson) on Jun 01, 2006 at 12:10 UTC

    CGI::Application::Plugin::DBH is quite nice, but i find myself doing a lot of SQL by hand that i shouldn't, especially since i'm not as versed in SQL as i should be for some of the queries i try and do.

    That's where Class::DBI or DBIx::Class comes in nice and handy, although I have trouble understanding how it handles relationships, but, that's a topic for another thread :-)

    meh.