x
Loading
 Loading
Hello, Guest | Login | Register

CGI::Prototype, Part Three

In the last two columns, I introduced my CGI::Prototype generic controller framework. This time, let’s continue the examination with a description of a real workhorse subclass, CGI::Prototype::Hidden.

In the last two columns, I introduced my CGI::Prototype generic controller framework. This time, let’s continue the examination with a description of a real workhorse subclass, CGI::Prototype::Hidden.
The CGI::Prototype framework can be used to write applications, but lacks the concrete means by which the state of the application can be deduced. I wrote the code expecting that various strategies for state dispatch (hidden fields, cookies, server-side databases, mangled URLs) would be coded as subclasses of CGI::Prototype. The first to be coded is hidden fields, implemented as CGI::Prototype::Hidden.
For CGI::Prototype::Hidden (CGIPH), the state must be a simple, arbitrary keyword: something that matches /^\w+$/. The state is used to select a particular class for the controller, along with the default template for that class. Once a state’s been selected, the corresponding class is loaded into the program (unless already defined), and used to determine the next step in the program. This “lazy loading” behavior permits a minimum of loading for CGI programs: at most, two different state-named classes are loaded per web hit.
CGIPH also defines a “wrapper” template to provide common definitions, headers, and footers for the processed templates, and a means by which the templates can be found “next to” the class source files. More on those later.
CGIPH is designed to make multi-page web applications easy to create and update. I found in practice that this is true: I recently created a fully functional administrative application for the booking…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace