tlm has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

Would any of you know where I can find an example/tutorial showing the use CGI::Prototype? The best I've found is the CGI::Prototype::Hidden that comes with the distribution, but it would help me a lot to look at a fuller example.

I have read merlyn's article discussing this module, but the source code that goes with this article consists only of a few isolated fragments for illustration. Also, I have read various perlmonks.org posts on CGI::Prototype, but I'm still not clear how one uses this module.

My biggest obstacle is Class::Prototyped (the superclass of CGI::Prototype). I understand the basic idea behind Self-like objects, but I don't understand why one would want to use them in place of regular Perl objects. It's clear from the article that Class::Prototyped's functionality is central to the "CGI::Prototype vision", but with the exception of the line

our $_mirror = __PACKAGE__->reflect;
at the top of the file, I don't see how CGI::Prototype::Hidden uses the fact that it is a subclass (or rather a subsubclass) of Class::Prototyped.

One problem I already see with the implementation of CGI::Prototype is that potential users not only must become familiar with it and with the Template Toolkit (which seems to me a reasonable thing to expect of a hard-working, underpaid CGI programmer), but must also become familiar with the workings of Class::Prototyped, even though this class has intrinsically nothing to do with writing CGI applications. I think users of CGI::Prototype should not have to know anything about Class::Prototyped to use CGI::Prototype effectively.

the lowliest monk

PS: I've also looked at CGI::Application, but I like C::P's MVC approach more than C::A's run mode approach. Granted, there's more stuff out there on how to use C::A, so I may ultimately go that route, but I'd like to give C::P a try first.

Replies are listed 'Best First'.
Re: Seeking enlightenment on CGI::Prototype
by Aristotle (Chancellor) on Mar 26, 2005 at 14:11 UTC

    Try merlyn‘s Introduction to CGI::Protoype. It actually explains why the bits of the sample application go where they do and illustrates in basic terms how to think the way the module calls for.

    Makeshifts last the longest.

Re: Seeking enlightenment on CGI::Prototype
by metaperl (Curate) on Mar 28, 2005 at 02:39 UTC
    Here is a 5 meg tarball that includes all the source for this website implemented in CGI::Prototype

    I dont make use of Class::Prototyped when using CGI::Prototype. I prefer to use normal Perl classes which works out under Class::Prototyped if you simply do a use base CGI::Prototype.

    You do not have to use Template Toolkit with CGI::Prototype. merlyn might be scaring off potential users with his misleading presentation. I use HTML::Seamstress to do my HTML templating and it works like a charm under CGI::Prototype.

    CGI::Prototype has a huge number of hurdles to cross. Merlyn can be very nasty to you at times. He will not create a mailing list. The docs are incomplete. But I will say one thing and I mean every word of it: the module ROCKS and I don't plan to use anything else for my CGI /mod_perl development. If I'm willing to put up with all the listed bs and still make exclusive use of it, that's saying something about how unique and good it is.

      Merlyn can be very nasty to you at times.
      I'd like you to point out a time when you think I intended to be nasty. I suspect it's in your head, not mine.
      He will not create a mailing list.
      I merely said that I will not create a list, as I don't have the resources to do that. Nothing is stopping you from creating one of your own. In fact, if you do, I'll be sure to put it in the next docs.
      The docs are incomplete.
      It's completely documented as a reference. What you're missing is a tutorial, and more examples. But that doesn't make it incomplete, just not useful to you. And even as incomplete as you say they are, you seem to have successfully achieved what you wanted. So I'm not sure why you raise that point. I don't know any product that couldn't be better documented!

      In fact, I appreciate that you made your tarball available. Unfortunately, all of the non-trivial uses I've made of CGI-P are all proprietary products right now. I still intend on creating some non-trivial non-encumbered examples, but the resource pile is small at the moment.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.