in reply to Draft of CGI::Application Tutorial -- RFC

I made an attempt at something similar a couple of years ago but I think you’ve made a better go of it (at least you’ve had some replies :-).

I agree with moritz though, and you should include it in your post. I also agree you could remove the bold font.

Getting the file structure right is indeed key. Shouldn’t all your modules be under a lib dir? Perhaps two, one for base/common modules and separate lib dirs for each app with a corresponding structure below those for ‘helper’ modules much like Perl does it. Also you have a conf file in the same dir as a module. They might be more at home in a conf dir. There is no need for template files to be under your document root (fewer files here the better, imo) so perhaps a tmpl dir too under your app dir.

Your base class has hard coded dirs for finding the cnf file and the tmpl files and you don’t specify any for your sessions. I think this is something that the instance script could usefully pass to the app module. The instance script already has a hard coded path to the lib so perhaps you could pass that and your base module could then find everything it needs (e.g. tmp, data, tmpl, sessions, cnf).

I think there may be a missing closing and opening code tag just before the Common.pm code.

Well done and good luck!

  • Comment on Re: Draft of CGI::Application Tutorial -- RFC

Replies are listed 'Best First'.
Re^2: Draft of CGI::Application Tutorial -- RFC
by bradcathey (Prior) on Jul 17, 2008 at 14:36 UTC

    Thanks for your comments, wfsp

    Shouldn’t all your modules be under a lib dir?

    I have been back and forth on a lib directory. It is expected, but for some reason I always equate lib with the Perl app itself, and CPAN modules and the like. But I'm open and want to do what's best for the tutorial.

    Also you have a conf file in the same dir as a module.

    I usually put a .conf file in it's own directory, but was trying to keep it simple. But to your point, see below.

    /opt/foobar/lib/---+ | | | | | Foobar_Super.pm | | | Common.pm | | | /Acmecorp/---+ | | | Contact.pm | | | /conf/---+ | | | acmecorp.conf | | /var/www/acmecorp/--+ | home.html | /contact/----+ | | | index.cgi | /templates/---+ | | | contact.tmpl | thankyou.html
    There is no need for template files to be under your document root

    The reason I do this: we are a design firm and my designers need access to the templates, but I don't want them mucking around on the app side. But to your point, I have done this in the past. What would be best for the tutorial?

    Your base class has hard coded dirs for finding the cnf file and the tmpl files and you don’t specify any for your sessions.

    Hmmmm, not sure how this would look for session. Can you give me an example?

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot