Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

CGI::App/TT/DBIx::Class design question...

by uG (Scribe)
on Aug 18, 2008 at 07:11 UTC ( [id://704866]=perlquestion: print w/replies, xml ) 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?

Replies are listed 'Best First'.
Re: CGI::App/TT/DBIx::Class design question...
by Khen1950fx (Canon) on Aug 18, 2008 at 09:44 UTC
Re: CGI::App/TT/DBIx::Class design question...
by RatKing (Acolyte) on Aug 18, 2008 at 14:28 UTC

    It seems like a good thing to do, simply get all owner information and their pets (names/ID's or so) during prerun of Mod::Owner and get the Pet information and user (name/id) during the Mod::Pet prerun but...

    But, what if some crazy pet owner starts breeding then and ends up having hunderds up on hunderds... you might be fetching way to much data that in the end you never use thus making your application less scallable then you might want

    I would simply fetch the owner details during Mod::Owner prerun and fetch the pets information if and when the user needs this data, using a little AJAX/Web2.0 sauce you can do this even without reloading your page. This makes your application seem faster as you only load data when needed. You could even go as far as to only fetch 100 pets at a time if you suspect that those crazy pet breeders might cause you trouble in the future

    From a design perspective it makes perfect sense to fetch the data that you will be modifying but be very careful that you don't over eat on data that you do not need

      I actually planned on using AJAX just like you mentioned. I'm still studying up on it though and was going to implement it the old fashioned way in the mean time to work the bugs out :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://704866]
Approved by Erez
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-28 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found