Ok, so here are my proposed changes... --- CGI-Application-3.2_mls5/lib/CGI/Application.pm 2004-01-03 19:55:32.000000000 -0600 +++ Application.pm 2004-01-05 11:00:25.000000000 -0600 @@ -470,6 +470,17 @@ } +sub delete { + my $self = shift; + my ($param) = @_; + #return undef it it isn't defined + return undef if(!defined($param)); + + #simply delete this param from $self->{__PARAMS} + delete $self->{__PARAMS}->{$param}; +} + + sub query { my $self = shift; my ($query) = @_; @@ -1176,6 +1187,19 @@ =over 4 +=item delete() + + $webapp->delete('my_param'); + +The delete() method is used to delete a parameter that was previously +stored inside of your application either by using the PARAMS hash that +was passed in your call to new() or by a call to the param() method. +This is similar to the delete() method of CGI.pm. It is useful if your +application makes decisions based on the existence of certain params that +may have been removed in previous sections of your app or simply to +clean-up your param()s. + + =item dump() print STDERR $webapp->dump(); @@ -1576,6 +1600,33 @@ run mode has not yet been determined, such as during setup(), this method will return undef. + +=head2 Testing + +CGI::Application currently has no built-in testing methodology but we leave that +up to you. There are many testing structures and frameworks that are available for +testing Perl modules (ie, Test::Harness, Test::More). There are large numbers +of tools and frameworks for testing live web applications (WWW::Mechanize, HTTP::Test, +Apache::Test). We encourage you to look around CPAN and find the one that +best meets your needs. + +Since most of the module level testing frameworks require the output that is sent to +STDOUT be of a certain format, and since CGI::Application will print the output of it's +run modes directly to STDOUT this could cause problems. To avoid this simple set the +environment variable 'CGI_APP_RETURN_ONLY' to true and you can catch your output and +test it and then print your own message to STDOUT. For example + + $ENV{CGI_APP_RETURN_ONLY} = 1; + $output = $webapp->run(); + + #perform whatever test on the output that you want and then print to STDOUT + if($output =~ /GOOD/){ + print "ok 11\n"; + } else { + print "not ok 11\n"; + } + + =head2 A Note on CGI::Carp By default CGI::Application uses CGI::Carp to produce more useful error and --- CGI-Application-3.2_mls5/t/01cgiapp.t 2004-01-01 10:04:22.000000000 -0600 +++ 01cgiapp.t 2004-01-05 11:01:09.000000000 -0600 @@ -489,4 +489,40 @@ } +# Test 26: test delete() method by first setting some params and then deleting them +{ +$t26_ta_obj = TestApp5->new(); +$t26_ta_obj->param( + P1 => 'one', + P2 => 'two', + P3 => 'three'); +#a valid delete +$t26_ta_obj->delete('P2'); + +my $t1 = 0; +$t1 = 1 if( + scalar($t26_ta_obj->param()) == 2 + && ($t26_ta_obj->param('P1') eq 'one') + && (!defined($t26_ta_obj->param('P2'))) + && ($t26_ta_obj->param('P3') eq 'three') + ); + +#an invalid delete +my $result = $t26_ta_obj->delete('P4'); +my $t2 = 0; +$t2 = 1 if(!defined($result) + && ($t26_ta_obj->param('P1') eq 'one') + && (!defined($t26_ta_obj->param('P4'))) + && ($t26_ta_obj->param('P3') eq 'three') + ); + +if($t1 && $t2){ + print "ok 26\n"; +} else { + print "not ok 26\n"; +} +} + + + # All done! --- CGI-Application-3.2_mls5/Changes 2004-01-03 20:01:40.000000000 -0600 +++ Changes 2004-01-05 10:50:29.000000000 -0600 @@ -14,6 +14,9 @@ (Mark Stosberg) - Fixed typo in cgiapp_postrun documentation (Steve Hay) - Improved exception handling (Steve Hay) + - delete() method added to remove items stored using param() (Michael Peters) + - 'CGI_APP_RETURN_ONLY' environment variable that is used for testing is now + documented (Michael Peters) - Migrated from Makefile.PL to Build.PL. Either can now be used for installation. - Updated 'Changes' file to put new releases on top.
Thanks for all the feedback. Suggestions, changes, verbal (or written) abuse is welcome. Michael Peters Venzia --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]