in reply to Web framework under both mod_perl and CGI

Properly abstracting and separating the different layers should help make this a lot easier to do. I've had very good results using HTML::Template in conjunction with mod_perl. Here's how I'd suggest breaking things down.

Top Level Handler
This is specific to either mod_perl or the CGI environment. Have it do all the work of talking to Apache / the browser. Parameter parsing, session management, DBI connections, etc, etc. Basically all the things that could be different between mod_perl and CGI.
Page or function level objects
Takes a list of parameters, session info, DBI handle, etc. and returns a data structure of some sort based on the input. One of these handles a particular page or function in your app. These do not contain any mod_perl, CGI or (insert template mechanism here ) specific things.
HTML suitable for which ever template mechanism you use
The benefits to keeping your HTML out of your code are very, very numerous.

So the chain of events goes kinda like this. The CGI or mod_perl handler, gets called for every page in your app. It does all the 'common stuff' that every CGI or mod_perl handler does. It then calls the appropriate page handling module passing along all the parameters. The page handling module does whatever processing you need for that page (database calls, generation of error message), and passes back a data structure of the results. The top level handler takes that structure, feeds it through the appropriate template and send the output to the client.

Here's some of the benefits.

Good luck, and I hope this helps.

/\/\averick

  • Comment on Re: Web framework under both mod_perl and CGI

Replies are listed 'Best First'.
Re: Re: Web framework under both mod_perl and CGI
by IOrdy (Friar) on Aug 06, 2001 at 04:52 UTC
    Maverick is spot on. As a primarily a graphic designer rather than a coder, seperating your design from your code makes a world of difference down the track when a redesign is due.

    Working with a neatly OO web application written in mod_perl/HTML::Template etc. is always a pleasure.

    iordy.com