in reply to Mason & DBI driving me nuts
Having developed *many* Mason, projects I can share some quick words of wisdom.
- Mason isn't fun for *large* projects, and large is subjective, if you think of your own undertaking as large, you might want to look into a tool that lends itself to better code, ie an mvc type of tool
- Learn the ins and outs of Mason - buy the Mason book the whole framework is a cinch to down, and get running
- If you chose not use an ORM consider using $sth->fetchrow_hashref - for clarity when possible
- Move the connect string out of the mason root!!! Use Apache::DBI, or when you fail to connect, Mason will stack dump w/ source (default) and spit out your pw
- Use autocommit=>0 (dbi param, makes you $dbh->commit, and $dbh->rollback - the right way)
- Make $dbh a PerlGlobal, consider another PerlGlobal ($s) for the session, I also use one more, ($u for the user), it is silly to pass these around to comps or to reinvent the wheel on every invocation - Every modern framework, agrees in putting these into a global (globals are declared with PerlGlobal, and NOT localized/initialized anywhere in your code, only set to different variables)
If you plan on doing web development, you will probably move away from Mason at some point, MVC really is an incredibly better way to design. I should have my session code, and root autohandlers on PM if I don't and you want that code, (my mason based framework I used for many years, you can have it)
Evan Carroll
www.EvanCarroll.com
In Section
Seekers of Perl Wisdom