r29225 - in /branches/upstream/libcgi-application-perl/current: Changes MANIFEST META.yml lib/CGI/Application.pm t/lib/TestApp13.pm t/lib/TestApp14.pm t/query.t
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Sun Jan 4 12:06:46 UTC 2009
Author: ansgar-guest
Date: Sun Jan 4 12:06:43 2009
New Revision: 29225
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=29225
Log:
[svn-upgrade] Integrating new upstream version, libcgi-application-perl (4.21)
Added:
branches/upstream/libcgi-application-perl/current/t/lib/TestApp13.pm
branches/upstream/libcgi-application-perl/current/t/lib/TestApp14.pm
branches/upstream/libcgi-application-perl/current/t/query.t
Modified:
branches/upstream/libcgi-application-perl/current/Changes
branches/upstream/libcgi-application-perl/current/MANIFEST
branches/upstream/libcgi-application-perl/current/META.yml
branches/upstream/libcgi-application-perl/current/lib/CGI/Application.pm
Modified: branches/upstream/libcgi-application-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/Changes?rev=29225&op=diff
==============================================================================
--- branches/upstream/libcgi-application-perl/current/Changes (original)
+++ branches/upstream/libcgi-application-perl/current/Changes Sun Jan 4 12:06:43 2009
@@ -1,4 +1,15 @@
Revision history for CGI::Application.
+
+4.21 Sat Jan 3, 2009
+
+ [FEATURES]
+ - This now works:
+ $webapp->query($new_query_object);
+ Setting a new query object can be useful in combination with
+ CGI::Application::Server. (Jaldhar Vyas)
+
+ [DOCUMENTATION]
+ - More typo fixes (Lyle)
4.20 Sat Nov 1, 2008
Modified: branches/upstream/libcgi-application-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/MANIFEST?rev=29225&op=diff
==============================================================================
--- branches/upstream/libcgi-application-perl/current/MANIFEST (original)
+++ branches/upstream/libcgi-application-perl/current/MANIFEST Sun Jan 4 12:06:43 2009
@@ -27,6 +27,7 @@
t/mode_param_path_info.t
t/mode_param_overwritten.t
t/load_tmpl_hook.t
+t/query.t
t/lib/TestApp.pm
t/lib/TestApp2.pm
t/lib/TestApp3.pm
@@ -39,5 +40,7 @@
t/lib/TestApp10.pm
t/lib/TestApp11.pm
t/lib/TestApp12.pm
+t/lib/TestApp13.pm
+t/lib/TestApp14.pm
t/lib/TestCGI.pm
t/lib/templates/test.tmpl
Modified: branches/upstream/libcgi-application-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/META.yml?rev=29225&op=diff
==============================================================================
--- branches/upstream/libcgi-application-perl/current/META.yml (original)
+++ branches/upstream/libcgi-application-perl/current/META.yml Sun Jan 4 12:06:43 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: CGI-Application
-version: 4.11
+version: 4.21
author:
- Jesse Erlbaum <jesse at erlbaum.net>
- Mark Stosberg <mark at summersault.com>
@@ -16,7 +16,7 @@
provides:
CGI::Application:
file: lib/CGI/Application.pm
- version: 4.11
+ version: 4.21
CGI::Application::Mailform:
file: lib/CGI/Application/Mailform.pm
generated_by: Module::Build version 0.2611
Modified: branches/upstream/libcgi-application-perl/current/lib/CGI/Application.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/lib/CGI/Application.pm?rev=29225&op=diff
==============================================================================
--- branches/upstream/libcgi-application-perl/current/lib/CGI/Application.pm (original)
+++ branches/upstream/libcgi-application-perl/current/lib/CGI/Application.pm Sun Jan 4 12:06:43 2009
@@ -3,7 +3,7 @@
use strict;
use Class::ISA;
-$CGI::Application::VERSION = '4.20';
+$CGI::Application::VERSION = '4.21';
my %INSTALLED_CALLBACKS = (
# hook name package sub
@@ -464,18 +464,14 @@
my $self = shift;
my ($query) = @_;
- # We're only allowed to set a new query object if one does not yet exist!
- unless (exists($self->{__QUERY_OBJ})) {
- my $new_query_obj;
-
- # If data is provided, set it! Otherwise, create a new one.
- if (defined($query)) {
- $new_query_obj = $query;
- } else {
- $new_query_obj = $self->cgiapp_get_query();
+ # If data is provided, set it! Otherwise, create a new one.
+ if (defined($query)) {
+ $self->{__QUERY_OBJ} = $query;
+ } else {
+ # We're only allowed to create a new query object if one does not yet exist!
+ unless (exists($self->{__QUERY_OBJ})) {
+ $self->{__QUERY_OBJ} = $self->cgiapp_get_query();
}
-
- $self->{__QUERY_OBJ} = $new_query_obj;
}
return $self->{__QUERY_OBJ};
@@ -1037,7 +1033,7 @@
all the arguments which were sent to the new() method.
An example of the benefits provided by utilizing this hook is
-creating a custom "application super-class" from which which all
+creating a custom "application super-class" from which all
your web applications would inherit, instead of CGI::Application.
Consider the following:
@@ -1165,13 +1161,13 @@
Override this method to retrieve the query object if you wish to use a
different query interface instead of CGI.pm.
-CGI.pm is only loaded to provided query object is only loaded if it used on a given request.
+CGI.pm is only loaded if it is used on a given request.
If you can use an alternative to CGI.pm, it needs to have some compatibility
with the CGI.pm API. For normal use, just having a compatible C<param> method
should be sufficient.
-If use the C<path_info> option to the mode_param() method, then we will call
+If you use the C<path_info> option to the mode_param() method, then we will call
the C<path_info()> method on the query object.
If you use the C<Dump> method in CGI::Application, we will call the C<Dump> and
@@ -1345,6 +1341,12 @@
method supports passing in your existing query object on construction using
the QUERY attribute.
+There are a few rare situations where you want your own query object to be
+used after your Application Module has already been constructed. In that case
+you can pass it to c<query()> like this:
+
+ $webapp->query($new_query_object);
+ my $q = $webapp->query(); # now uses $new_query_object
=head3 run_modes()
Added: branches/upstream/libcgi-application-perl/current/t/lib/TestApp13.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/t/lib/TestApp13.pm?rev=29225&op=file
==============================================================================
--- branches/upstream/libcgi-application-perl/current/t/lib/TestApp13.pm (added)
+++ branches/upstream/libcgi-application-perl/current/t/lib/TestApp13.pm Sun Jan 4 12:06:43 2009
@@ -1,0 +1,53 @@
+package TestApp13;
+use strict;
+use CGI::Application;
+ at TestApp13::ISA = qw(CGI::Application);
+
+# Prevent output to STDOUT
+$ENV{CGI_APP_RETURN_ONLY} = 1;
+
+sub setup {
+ my $self = shift;
+ $self->run_modes( [ qw( mode1 mode2 ) ] );
+ $self->start_mode( 'mode1' );
+ $self->error_mode( 'error' );
+}
+
+
+sub mode1 {
+ my $self = shift;
+ my $file;
+ open ( $file, "t/lib/templates/test.tmpl" )
+ || die "Cannot open testing template";
+ my $template = $self->load_tmpl( $file, 'die_on_bad_params' => 0 );
+ $template->param( 'ping' => "HELLO!" );
+ my $output = $template->output;
+ close ( $file );
+ $output;
+}
+
+sub mode2 {
+ my $self = shift;
+ my $template_string = <<_EOF_;
+<html>
+<head>
+<title>Simple Test</title>
+</head>
+<body>
+What's this: <!-- TMPL_VAR NAME="ping" -->
+</body>
+</html>
+_EOF_
+
+ my $template = $self->load_tmpl( \$template_string, 'die_on_bad_params' => 0 );
+ $template->param( 'ping' => 'HELLO!' );
+ $template->output;
+}
+
+sub error {
+ my $self = shift;
+ return "ERROR";
+}
+
+1;
+
Added: branches/upstream/libcgi-application-perl/current/t/lib/TestApp14.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/t/lib/TestApp14.pm?rev=29225&op=file
==============================================================================
--- branches/upstream/libcgi-application-perl/current/t/lib/TestApp14.pm (added)
+++ branches/upstream/libcgi-application-perl/current/t/lib/TestApp14.pm Sun Jan 4 12:06:43 2009
@@ -1,0 +1,21 @@
+package TestApp14;
+use base 'CGI::Application';
+use warnings;
+use strict;
+
+sub setup {
+ my $self = shift;
+ $self->run_modes([qw/ start /]);
+ $self->tmpl_path('t/lib/templates');
+}
+
+sub start {
+ my $self = shift;
+
+ my $t = $self->load_tmpl('test.tmpl');
+ $t->param(ping => $self->query->param('message'));
+
+ return $t->output();
+}
+
+1;
Added: branches/upstream/libcgi-application-perl/current/t/query.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcgi-application-perl/current/t/query.t?rev=29225&op=file
==============================================================================
--- branches/upstream/libcgi-application-perl/current/t/query.t (added)
+++ branches/upstream/libcgi-application-perl/current/t/query.t Sun Jan 4 12:06:43 2009
@@ -1,0 +1,27 @@
+# test the query() method
+
+use Test::More 'no_plan';
+use CGI;
+
+# Include the test hierarchy
+use lib 't/lib';
+
+use TestApp14;
+
+# Prevent output to STDOUT
+$ENV{CGI_APP_RETURN_ONLY} = 1;
+
+# Test query()
+{
+ my $cgi = CGI->new('message=hello');
+ my $ta_obj = TestApp14->new(QUERY => $cgi);
+ my $output = $ta_obj->run();
+
+ like($output, qr/---->hello<----/);
+
+ my $cgi2 = CGI->new('message=goodbye');
+ $ta_obj->query($cgi2);
+ $output = $ta_obj->run();
+
+ like($output, qr/---->goodbye<----/);
+}
More information about the Pkg-perl-cvs-commits
mailing list