|Think about Loose Coupling|
CGI::App/TT/DBIx::Class design question...by uG (Scribe)
|on Aug 18, 2008 at 07:11 UTC||Need Help??|
uG has asked for the
wisdom of the Perl Monks concerning the following question:
Its been quite a few years, but here goes my first post :)
I've been working with CGI::Application, Template Toolkit, and DBIx::Class recently. Between the three, my interest in actually pushing through projects has increased dramatically. Unfortunately i'm not used to working with such a framework type deal.
On to the question...
I have a table User and a table Pets. The DBIx relation is that each User has many pets, and each pet has one owner. There are 2 cgi::app modules, Mod::User and Mod::Pet that are used for modifying certain things for each User or Pet. So, couldn't I create my scheme and get my resultset in cgiapp_prerun (in each module) and use that data throughout the module? And just close the database connection on the teardown? I'm sorry if this is more of a design related question. I'd love for it to be that simple... ie. Mod::User's cgiapp_prerun gets the resultset for a specific user, and Mod::Pet's cgiapp_prerun gets the resultset for all pets of a specific user. Then I could just access these resultsets later on in the code.
Does this sound like a good idea?