O'Reilly logo

Practical Internet Groupware by Jon Udell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Receiving and Validating Docbase Records

The Docbase::Input module will automatically preview input received from a form’s handler. We’ll see how that works shortly. But validating the fields of a record is the responsibility of each Docbase instance. That’s done by customizing the handler for each instance. The handler is always called submit.pl. For the ProductAnalysis docbase, the customized handler—shown in Example 6.4—is stored as /web/cgi-bin/Docbase/ProductAnalysis/submit.pl.

Example 6-4. The ProductAnalysis Version of submit.pl

#!/usr/bin/perl -w ########################################################### # boilerplate for every docbase ########################################################### use strict; use Docbase::Input; use TinyCGI; my $tc = TinyCGI->new(); my $vars = $tc->readParse(); # collect CGI args print $tc->printHeader; # start emitting page my $app = $vars->{app}; my $di = Docbase::Input->new($app); foreach my $key (keys %$vars) # basic cleanup of input text { $vars->{$key} = $di->cleanseInput($vars->{$key}); } my ($warnings,$errors) = docbase_validate(); # validate input $di->processInput($vars,$warnings,$errors); # process input and warnings/errors ########################################################### # custom validation tailored for each docbase ########################################################### sub docbase_validate { my (@warnings) = (); my (@errors) = (); my $mailpat = $di->getMailPat; # accumulate warnings unless ( $vars->{'contact'} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required