Let's take a look at merlyn's analysis of CGI programming:

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

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

This post aims to expand and clarify step #2 above with a newly discovered issue.

When a user submits a form, your response may entail several different actions:
validation
was the submitted form data intelligible?
authentication
was the submitted form data/cookie something that allows you to figure out who this person is?
authorization
was the person who submitted form data/cookie somethone that has a right to request this page?
execution
Perform the actions requested by hitting the submit button. E.g. update user info.

So now that you understand these steps, let's see why I am bothering posting all this. Let's assume you have presented a user with an information update screen. The user enters some (possibly invalid) data and hits submit. The following then occurs in CGI::Prototype::activate

  1. the dispatch routine is called. This routine will determine that a user has submitted user update information. Now it is up to a package, say, MyApp::Update::Validate to determine the response. Here is pseudocode for that:
    package MyApp::Update::Validate; sub response { my $response; if (not validated) { $response = 'Redo'; } elsif (not authenticated) { $response = 'NotAuthenticated' } elsif (not authorized) { $response = 'NotAuthorized'; } else { $response = 'HandleUpdate' # model action: update user info } $response = "MyApp::Login::$response"; return $response; }

But the question becomes where do model actions occur and how do we change pages based on this?


In reply to CGI::Prototype - let me clarify the response phase for you by metaperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.