[Israel.pm] Talk: A natural flow for web apps

Scott Weisman sweisman at pobox.com
Wed Mar 24 06:56:01 PST 2004

I have a web site I am responsible for where I developed a mechanism (I don't
take credit for the technique since I'm sure others have done it before) for
handling getting data filled accross multiple forms without any hidden
variables. I cache everything using the Cache::FileCache module (this is
version 1.x, version 2.x uses a different naming scheme). I was trying to come
up with a generic scheme to to check which data was still needed and keep
displaying the proper page until all required data was provided. I came very
close to achieving this, but after numerous small problems, I concluded it was
a waste of time, it was easier to use a slightly less generic mechanism and
reconfigure the page processing if I move form elements from one page to
another. The URL naming convention I came up with also cleverly (in my
opinion) split up display and processing.

/site/object/view2 displays a form that submits to /site/object/validate2, the
validate1() function (object method, really), then processes the form,
validates the data, and decides the next step to take -- either the data is
good and finish (or go on to the next step), redisplay the page, or if the
user is entering in the middle (eg he should go to view1) then redirect to the
beginning of the process.

There are now CPAN modules that do a lot of the hard stuff to make this an
easier process. CGI::Application is one such, Simon Cozens' Maypole is
another, newer, more interesting example.


On Sat, 20 Mar 2004 00:26:36 +0200 "Ran Eilam" <eilara at cortext.co.il> wrote:

> Name: From the Command Line to the Browser
> Length: 20 minutes
> Summary: will show a very experimental web development trick, that lets
> you call web pages as subs.
> Consider a command line application that gets 2 numbers and prints their
> sum:
>   sub flow {
>      my $a = prompt('Enter a number:');
>      my $b = prompt('Enter another number:');
>      prompt('Sum is: '. ($a + $b). '. Hit Enter to continue.');
>   }
> It is easy to write a prompt() that will do what we need. Something
> like:
>   sub prompt {
>      my $message = shift;
>      print "$message\n";
>      chomp(my $out = <>);
>      return $out;
>   }
> How do you write a prompt() that will allow flow() to run unchanged, but
> as a web app consisting of 3 pages?
> Having prompt() itself accept an HTTP request from a connection, is not
> allowed. Why? flow() needs to run in a standard web server, like
> mod_perl, and they dont allow that. flow() will be called from an HTTP
> request handler, thus the request has already been accepted.
> During the talk we will look at a working solution, and see why it is
> problematic.
> Ran
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://www.perl.org.il/mailman/listinfo/perl

More information about the Perl mailing list