Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    CGI::Prototype 0.9054

    Download button

    No screenshots available
    Downloads: 321  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Randal L. Schwartz | More programs
    Perl Artistic License / FREE
    November 15th, 2011, 00:51 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    CGI::Prototype description

    Create a CGI application by subclassing

    The core of every CGI application seems to be roughly the same:

     * Analyze the incoming parameters, cookies, and URLs to determine the state of the application (let's call this "dispatch").
     * Based on the current state, analyze the incoming parameters to respond to any form submitted ("respond").
     * From there, decide what response page should be generated, and produce it ("render").

    CGI::Prototype is a Perl module that creates a Class::Prototyped engine for doing all this, with the right amount of callback hooks to customize the process. Because I'm biased toward Template Toolkit for rendering HTML, I've also integrated that as my rendering engine of choice. And, being a fan of clean MVC designs, the classes become the controllers, and the templates become the views, with clean separation of responsibilities, and CGI::Prototype a sort of "archetypal" controller.

    You can create the null application by simply activating it:

     use CGI::Prototype;
     CGI::Prototype->activate;


    But this won't be very interesting. You'll want to subclass this class in a Class::Prototyped-style manner to override most of its behavior. Slots can be added to add or alter behavior. You can subclass your subclasses when groups of your CGI pages share similar behavior. The possibilities are mind-boggling.

    Within the templates, self refers to the current controller. Thus, you can define callbacks trivially. In your template, if you need some data, you can pull it as a request:

     [% my_data = self.get_some_big_data %]

    which is supplied by simply adding the same slot (method or data) in the controlling class:

     sub get_some_big_data {
     my $self = shift;
     return $self->some_other_method(size => 'big');
     }


    And since the classes are hierarchical, you can start out with an implementation for one page, then move it to a region or globally quickly.

    Although the name CGI::Prototype implies a CGI protocol, I see no reason that this would not work with Apache::Registry in a mod_perl environment, or a direct content handler such as:

     package My::App;
     use base CGI::Prototype;
     sub handler {
     __PACKAGE__->activate;
     }


    Note that the $r request object will have to be created if needed if you use this approach.

    SYNOPSIS

     package My::HelloWorld;
     use base CGI::Prototype;

     sub template {

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    CGI application | Perl module | CGI application | subclassing | prototype

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM