r59959 - in /trunk/libdancer-perl: ./ debian/ lib/ lib/Dancer/ lib/Dancer/Logger/ lib/Dancer/Route/ lib/Dancer/Serializer/ lib/Dancer/Template/ t/ t/02_request/ t/07_apphandlers/ t/10_template/ t/14_serializer/ t/15_plugins/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Thu Jul 1 19:44:12 UTC 2010
Author: jawnsy-guest
Date: Thu Jul 1 19:44:06 2010
New Revision: 59959
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=59959
Log:
integrate new upstream version
Added:
trunk/libdancer-perl/t/14_serializer/07_bug_57805.t
- copied unchanged from r59958, branches/upstream/libdancer-perl/current/t/14_serializer/07_bug_57805.t
trunk/libdancer-perl/t/15_plugins/03_namespace.t
- copied unchanged from r59958, branches/upstream/libdancer-perl/current/t/15_plugins/03_namespace.t
trunk/libdancer-perl/t/TestAppExt.pm
- copied unchanged from r59958, branches/upstream/libdancer-perl/current/t/TestAppExt.pm
trunk/libdancer-perl/t/TestPlugin.pm
- copied unchanged from r59958, branches/upstream/libdancer-perl/current/t/TestPlugin.pm
Modified:
trunk/libdancer-perl/CHANGES
trunk/libdancer-perl/MANIFEST
trunk/libdancer-perl/META.yml
trunk/libdancer-perl/Makefile.PL
trunk/libdancer-perl/debian/changelog
trunk/libdancer-perl/lib/Dancer.pm
trunk/libdancer-perl/lib/Dancer/Handler.pm
trunk/libdancer-perl/lib/Dancer/Introduction.pod
trunk/libdancer-perl/lib/Dancer/Logger.pm
trunk/libdancer-perl/lib/Dancer/Logger/Abstract.pm
trunk/libdancer-perl/lib/Dancer/Plugin.pm
trunk/libdancer-perl/lib/Dancer/Renderer.pm
trunk/libdancer-perl/lib/Dancer/Request.pm
trunk/libdancer-perl/lib/Dancer/Route/Registry.pm
trunk/libdancer-perl/lib/Dancer/Serializer/Abstract.pm
trunk/libdancer-perl/lib/Dancer/Serializer/Mutable.pm
trunk/libdancer-perl/lib/Dancer/Template/Simple.pm
trunk/libdancer-perl/t/02_request/14_uploads.t
trunk/libdancer-perl/t/02_request/15_headers.t
trunk/libdancer-perl/t/07_apphandlers/01_base.t
trunk/libdancer-perl/t/07_apphandlers/02_apache2_plack.t
trunk/libdancer-perl/t/07_apphandlers/03_psgi_app.t
trunk/libdancer-perl/t/10_template/03_simple.t
trunk/libdancer-perl/t/10_template/05_template_toolkit.t
trunk/libdancer-perl/t/10_template/index.txt
trunk/libdancer-perl/t/14_serializer/05_live.t
Modified: trunk/libdancer-perl/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/CHANGES?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/CHANGES (original)
+++ trunk/libdancer-perl/CHANGES Thu Jul 1 19:44:06 2010
@@ -1,3 +1,39 @@
+Dancer 1.1805
+ [ Alexis Sukrieh ]
+ * Fix for RT#56239
+ logger calls are better traced
+ * Fix for GH#72
+ New keyword 'load_plugin' for loading a plugin in the current namespace.
+ Plugins can be used anywhere thanks to that method.
+
+ [ Minty ]
+ * Update Introduction pod with (required) -a dancer opt (Murray, 5 hours ago)
+ * Bump HTTP::Body dependency to 1.07 (Murray, 6 hours ago)
+
+Dancer 1.804
+ [ sebastian de castelberg ]
+ * Fix priority in D::S::Mutable.
+
+ [ David Precious ]
+ * Fix test failures with old Plack versions (Issue 73).
+ * Don't surround content with <p> tags in layout.
+ * Add $ENV{REMOTE_ADDR} in core log messages
+
+ [ SawyerX ]
+ * Fix issue #75, reported by nanis.
+ perl -MDancer -e "print $Dancer::VERSION" now works as expected
+
+ [ Daniel Pittman ]
+ * FIX for issue #80
+ Make sure the tempfiles created during uploads are removed when the
+ request object dies.
+
+ [ Alexis Sukrieh ]
+ * FIX for bug RT#58355
+ Rewrite of Dancer::Template::Simple's parser, now more robust,
+ based on Perl's regexp engine.
+ * FIX a warning when remote_address is undefined
+
Dancer 1.1803
[ Alexis Sukrieh ]
* Fix for issue #69
@@ -22,9 +58,9 @@
prevent errors if Module::Refresh is not installed.
Dancer 1.1800
- [ Alexis Sukrieh ]
- * merge of the devel branch into master, first stable release of
- 1.178_01 and 1.178_02
+ [ Alexis Sukrieh ]
+ * merge of the devel branch into master, first stable release of
+ 1.178_01 and 1.178_02
Dancer 1.178_02
[ Alexis Sukrieh ]
@@ -33,33 +69,33 @@
Dancer 1.178_01
- [ Alexis Sukrieh ]
- * New logger for sending log message to STDERR: Dancer::Logger::Console
- Thanks to Gabor Szabo for the idea.
- * Logger engines don't have anymore to implement _format(), they can use
- $self->format_message instead.
- * New log level: "core" for letting Dancer's core express itself on crucial
+ [ Alexis Sukrieh ]
+ * New logger for sending log message to STDERR: Dancer::Logger::Console
+ Thanks to Gabor Szabo for the idea.
+ * Logger engines don't have anymore to implement _format(), they can use
+ $self->format_message instead.
+ * New log level: "core" for letting Dancer's core express itself on crucial
events.
That way, when the app config sets log to "core", any core messages is
- sent to the logger, and the end-user can see which route is chosen for
- each request received.
- Thanks to Gabor Szabo for the idea.
- * New class Dancer::Timer added so any logger engine can now show a timer
+ sent to the logger, and the end-user can see which route is chosen for
+ each request received.
+ Thanks to Gabor Szabo for the idea.
+ * New class Dancer::Timer added so any logger engine can now show a timer
string.
* Scaffolded applications are now built like a CPAN distribution, with a
Makefile.PL
- and test scripts (thanks to Gabor Szabo for the idea).
- * Added Dancer::Test to provide helpers for writing test script for Dancer
- applications
- * FIX bug when returning a void context after redirecting a route.
- Thanks to Juan J. MartÃnez for the report.
- * Add support for request headers in Dancer::Request
+ and test scripts (thanks to Gabor Szabo for the idea).
+ * Added Dancer::Test to provide helpers for writing test script for Dancer
+ applications
+ * FIX bug when returning a void context after redirecting a route.
+ Thanks to Juan J. MartÃnez for the report.
+ * Add support for request headers in Dancer::Request
* Add support for halt() in Dancer's syntax.
- [ Alex Kapranof ]
- * Support for on-the-fly charset encoding when the setting is set and a
+ [ Alex Kapranof ]
+ * Support for on-the-fly charset encoding when the setting is set and a
content is sent by Dancer and needs to be encoded.
- The response Content-Type is updated accordingly as well.
+ The response Content-Type is updated accordingly as well.
[ Sawyer X ]
* Adding "import_warnings" settings. On by default, but allows to disable
@@ -103,14 +139,14 @@
* Plugins configuration
* Cleaning up tests
- [ Alexis Sukrieh ]
- * New serializer: Dumper for easily output dumped variable
- in text/plain.
- * Before filters can now access route params
+ [ Alexis Sukrieh ]
+ * New serializer: Dumper for easily output dumped variable
+ in text/plain.
+ * Before filters can now access route params
* Support for '.' as a token separator in params parsing
- * The standalone server respect the 'access_log' setting,
- the starting banner is printed on STDERR only if the
- setting is set to true.
+ * The standalone server respect the 'access_log' setting,
+ the starting banner is printed on STDERR only if the
+ setting is set to true.
[ Sawyer X ]
* Fixed Windows PSGI.URL_SCHEME bug, causing tests to fail
@@ -217,7 +253,7 @@
* FIX Params are not polluted anymore by the 'splat' keyword when no capture
is needed by the pattern.
* New feature 'auto_page' (closes: #41)
- Lets the user have automatic route resolution for
+ Lets the user have automatic route resolution for
requests that match an existing template in the views dir. Thanks to
David Precious for the idea and his help.
Modified: trunk/libdancer-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/MANIFEST?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/MANIFEST (original)
+++ trunk/libdancer-perl/MANIFEST Thu Jul 1 19:44:06 2010
@@ -172,9 +172,11 @@
t/14_serializer/04_mutable.t
t/14_serializer/05_live.t
t/14_serializer/06_serialize_response.t
+t/14_serializer/07_bug_57805.t
t/14_serializer/handler-helper.t
t/15_plugins/01_register.t
t/15_plugins/02_config.t
+t/15_plugins/03_namespace.t
t/16_timer/00_base.t
t/16_timer/02_hires.t
t/lib/EasyMocker.pm
@@ -184,5 +186,7 @@
t/lib/TestUtils.pm
t/manifest.t
t/pod.t
+t/TestAppExt.pm
+t/TestPlugin.pm
TODO
META.yml Module meta-data (added by MakeMaker)
Modified: trunk/libdancer-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/META.yml?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/META.yml (original)
+++ trunk/libdancer-perl/META.yml Thu Jul 1 19:44:06 2010
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Dancer
-version: 1.1803
+version: 1.1805
abstract: A minimal-effort oriented web application framework
author: []
license: perl
@@ -13,7 +13,7 @@
Encode: 0
File::Basename: 0
File::Spec: 0
- HTTP::Body: 0
+ HTTP::Body: 1.07
HTTP::Server::Simple::PSGI: 0.11
MIME::Types: 0
Test::More: 0.88
Modified: trunk/libdancer-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/Makefile.PL?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/Makefile.PL (original)
+++ trunk/libdancer-perl/Makefile.PL Thu Jul 1 19:44:06 2010
@@ -23,10 +23,10 @@
PREREQ_PM => {
# non-core
- 'HTTP::Body' => '0',
+ 'HTTP::Body' => '1.07', # needed for cleanup()
'HTTP::Server::Simple::PSGI' => '0.11',
'MIME::Types' => '0',
- 'URI' => 0,
+ 'URI' => '0',
# core
'File::Basename' => '0',
Modified: trunk/libdancer-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/debian/changelog?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/debian/changelog (original)
+++ trunk/libdancer-perl/debian/changelog Thu Jul 1 19:44:06 2010
@@ -1,14 +1,5 @@
-libdancer-perl (1.1803-1) UNRELEASED; urgency=low
-
- Lots of outstanding problems
-I: libdancer-perl: spelling-error-in-manpage usr/share/man/man3/Dancer::Cookbook.3pm.gz choosen chosen
-W: libdancer-perl: manpage-has-bad-whatis-entry usr/share/man/man3/Dancer::Introduction.3pm.gz
-W: libdancer-perl: manpage-has-bad-whatis-entry usr/share/man/man3/Dancer::Serializer::Mutable.3pm.gz
-W: libdancer-perl: manpage-has-bad-whatis-entry usr/share/man/man3/Dancer::Serializer::XML.3pm.gz
-
-W: libdancer-perl: manpage-has-errors-from-man usr/share/man/man3/Dancer::Serializer::YAML.3pm.gz 152: warning [p 1, 3.2i]: can't break line
-^ this is due to the weird chunk of text, probably from a failed merge/conflict
+libdancer-perl (1.1805-1) UNRELEASED; urgency=low
* Initial Release (Closes: #569974)
- -- Jonathan Yu <jawnsy at cpan.org> Wed, 26 May 2010 22:04:36 -0400
+ -- Jonathan Yu <jawnsy at cpan.org> Thu, 01 Jul 2010 16:32:09 -0400
Modified: trunk/libdancer-perl/lib/Dancer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer.pm (original)
+++ trunk/libdancer-perl/lib/Dancer.pm Thu Jul 1 19:44:06 2010
@@ -12,6 +12,7 @@
use Dancer::Error;
use Dancer::Helpers;
use Dancer::Logger;
+use Dancer::Plugin;
use Dancer::Renderer;
use Dancer::Response;
use Dancer::Route;
@@ -24,10 +25,12 @@
use Dancer::Handler;
use Dancer::ModuleLoader;
+use File::Spec;
+
use base 'Exporter';
$AUTHORITY = 'SUKRIA';
-$VERSION = '1.1803';
+$VERSION = '1.1805';
@EXPORT = qw(
ajax
any
@@ -52,6 +55,7 @@
layout
load
load_app
+ load_plugin
logger
mime_type
options
@@ -94,9 +98,9 @@
sub config { Dancer::Config::settings() }
sub content_type { Dancer::Response::content_type(@_) }
sub dance { Dancer::start(@_) }
-sub debug { Dancer::Logger->debug(@_) }
+sub debug { goto &Dancer::Logger::debug }
sub dirname { Dancer::FileUtils::dirname(@_) }
-sub error { Dancer::Logger->error(@_) }
+sub error { goto &Dancer::Logger::error }
sub send_error { Dancer::Helpers->error(@_) }
sub false {0}
sub from_dumper { Dancer::Serializer::Dumper::from_dumper(@_) }
@@ -152,13 +156,13 @@
sub uri_for { Dancer::SharedData->request->uri_for(@_) }
sub var { Dancer::SharedData->var(@_) }
sub vars { Dancer::SharedData->vars }
-sub warning { Dancer::Logger->warning(@_) }
+sub warning { goto &Dancer::Logger::warning }
sub load_app {
for my $app (@_) {
- Dancer::Logger->core("loading application $app");
-
- use lib path(dirname(abs_path($0)), 'lib');
+ Dancer::Logger::core("loading application $app");
+
+ use lib path( dirname( File::Spec->rel2abs($0) ), 'lib' );
# we want to propagate loading errors, so don't use ModuleLoader here
eval "use $app";
@@ -166,7 +170,9 @@
}
}
-
+sub load_plugin {
+ goto &Dancer::Plugin::load_plugin;
+}
# When importing the package, strict and warnings pragma are loaded,
# and the appdir detection is performed.
@@ -457,6 +463,17 @@
C<:syntax> option, in order not to change the application directory
(which has been previously set for the caller script).
+=head2 load_plugin
+
+Use this keyword to load plugin in the current namespace. As for
+load_app, the method takes care to set the libdir to the current
+C<./lib> directory.
+
+ package MyWebApp;
+ use Dancer;
+
+ load_plugin 'Dancer::Plugin::Database';
+
=head2 mime_type
Returns all the user-defined mime-types when called without parameters.
Modified: trunk/libdancer-perl/lib/Dancer/Handler.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Handler.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Handler.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Handler.pm Thu Jul 1 19:44:06 2010
@@ -18,11 +18,11 @@
# This is where we choose which application handler to return
sub get_handler {
if (setting('apphandler') eq 'PSGI') {
- Dancer::Logger->core('loading PSGI handler');
+ Dancer::Logger::core('loading PSGI handler');
return Dancer::Handler::PSGI->new;
}
else {
- Dancer::Logger->core('loading Standalone handler');
+ Dancer::Logger::core('loading Standalone handler');
return Dancer::Handler::Standalone->new;
}
}
@@ -30,8 +30,13 @@
# handle an incoming request, process it and return a response
sub handle_request {
my ($self, $request) = @_;
+ my $remote = $request->remote_address || '-';
+
Dancer::SharedData->reset_timer;
- Dancer::Logger->core("request: ".$request->method." ".$request->path);
+ Dancer::Logger::core(
+ "request: ".$request->method." ".$request->path
+ . " from " . $remote
+ );
# deserialize the request body if possible
$request = Dancer::Serializer->process_request($request) if setting('serializer');
@@ -90,7 +95,7 @@
$content = [ $content ];
}
- Dancer::Logger->core("response: ".$response->{status});
+ Dancer::Logger::core("response: ".$response->{status});
Dancer::SharedData->reset_all();
return [$response->{status}, $response->{headers}, $content];
}
Modified: trunk/libdancer-perl/lib/Dancer/Introduction.pod
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Introduction.pod?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Introduction.pod (original)
+++ trunk/libdancer-perl/lib/Dancer/Introduction.pod Thu Jul 1 19:44:06 2010
@@ -12,7 +12,7 @@
Create a web application using the dancer script:
- dancer MyApp
+ dancer -a MyApp
=head1 USAGE
@@ -622,4 +622,4 @@
# run the webserver
Dancer->dance;
-=cut
+=cut
Modified: trunk/libdancer-perl/lib/Dancer/Logger.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Logger.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Logger.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Logger.pm Thu Jul 1 19:44:06 2010
@@ -15,10 +15,10 @@
$logger = Dancer::Engine->build(logger => $name, $config);
}
-sub core { defined($logger) and $logger->core($_[1]) }
-sub debug { defined($logger) and $logger->debug($_[1]) }
-sub warning { defined($logger) and $logger->warning($_[1]) }
-sub error { defined($logger) and $logger->error($_[1]) }
+sub core { defined($logger) and $logger->core($_[0]) }
+sub debug { defined($logger) and $logger->debug($_[0]) }
+sub warning { defined($logger) and $logger->warning($_[0]) }
+sub error { defined($logger) and $logger->error($_[0]) }
1;
Modified: trunk/libdancer-perl/lib/Dancer/Logger/Abstract.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Logger/Abstract.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Logger/Abstract.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Logger/Abstract.pm Thu Jul 1 19:44:06 2010
@@ -36,7 +36,7 @@
$level = 'warn' if $level eq 'warning';
$level = sprintf('%5s', $level);
- my ($package, $file, $line) = caller(4);
+ my ($package, $file, $line) = caller(3);
$package ||= '-';
$file ||= '-';
$line ||= '-';
Modified: trunk/libdancer-perl/lib/Dancer/Plugin.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Plugin.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Plugin.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Plugin.pm Thu Jul 1 19:44:06 2010
@@ -15,7 +15,7 @@
my @_reserved_keywords = @Dancer::EXPORT;
-my $_keywords = [];
+my $_keywords = {};
sub plugin_setting {
my $plugin_orig_name = caller();
@@ -32,20 +32,38 @@
return undef;
}
-
sub register($$) {
my ($keyword, $code) = @_;
+ my $plugin_name = caller();
+
if (grep {$_ eq $keyword} @_reserved_keywords) {
die "You can't use $keyword, this is a reserved keyword";
}
- push @$_keywords, [$keyword => $code];
+ $_keywords->{$plugin_name} ||= [];
+ push @{$_keywords->{$plugin_name}}, [$keyword => $code];
}
sub register_plugin {
+ my ($application) = shift || caller(1);
my ($plugin) = caller();
- my ($application) = caller(1);
- for my $keyword (@$_keywords) {
+ export_plugin_symbols($plugin => $application);
+}
+
+sub load_plugin {
+ my ($plugin) = @_;
+ my $application = caller();
+
+ eval "use $plugin";
+ die "unable to load plugin '$plugin' : $@" if $@;
+
+ export_plugin_symbols($plugin => $application);
+}
+
+sub export_plugin_symbols {
+ my ($plugin, $application) = @_;
+
+ for my $keyword (@{ $_keywords->{$plugin} }) {
my ($name, $code) = @$keyword;
{
no strict 'refs';
Modified: trunk/libdancer-perl/lib/Dancer/Renderer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Renderer.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Renderer.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Renderer.pm Thu Jul 1 19:44:06 2010
@@ -117,7 +117,7 @@
undef $response;
$response = Dancer::Route->call($handler);
- Dancer::Logger->core("route: ".$handler->{route});
+ Dancer::Logger::core("route: ".$handler->{route});
return serialize_response_if_needed($response); #200
}
@@ -190,7 +190,7 @@
<body>
<h1><% title %></h1>
<div id="content">
-<p><% content %></p>
+<% content %>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer</a> <% version %>
Modified: trunk/libdancer-perl/lib/Dancer/Request.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Request.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Request.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Request.pm Thu Jul 1 19:44:06 2010
@@ -14,8 +14,8 @@
'user_agent', 'host',
'accept_language', 'accept_charset',
'accept_encoding', 'keep_alive',
- 'connection', 'accept',
- 'referer',
+ 'connection', 'accept',
+ 'accept_type', 'referer',
);
my $count = 0;
@@ -173,6 +173,7 @@
$self->{_http_body} =
HTTP::Body->new($self->content_type, $self->content_length);
+ $self->{_http_body}->cleanup(1);
$self->_build_params();
$self->_build_uploads unless $self->uploads;
}
@@ -212,6 +213,7 @@
$self->{keep_alive} = $self->{env}{HTTP_KEEP_ALIVE};
$self->{connection} = $self->{env}{HTTP_CONNECTION};
$self->{accept} = $self->{env}{HTTP_ACCEPT};
+ $self->{accept_type} = $self->{env}{HTTP_ACCEPT_TYPE};
$self->{referer} = $self->{env}{HTTP_REFERER};
$self->{x_requested_with} = $self->{env}{HTTP_X_REQUESTED_WITH};
}
Modified: trunk/libdancer-perl/lib/Dancer/Route/Registry.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Route/Registry.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Route/Registry.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Route/Registry.pm Thu Jul 1 19:44:06 2010
@@ -28,7 +28,7 @@
my $compiled_filter = sub {
return if Dancer::Response->halted;
- Dancer::Logger->core("entering before filter");
+ Dancer::Logger::core("entering before filter");
eval { $filter->() };
if ($@) {
my $err = Dancer::Error->new(
Modified: trunk/libdancer-perl/lib/Dancer/Serializer/Abstract.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Serializer/Abstract.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Serializer/Abstract.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Serializer/Abstract.pm Thu Jul 1 19:44:06 2010
@@ -18,6 +18,8 @@
# most serializer don't have to overload this one
sub support_content_type {
my ($self, $ct) = @_;
+ my @toks = split ';', $ct;
+ $ct = lc($toks[0]);
return $ct eq $self->content_type;
}
Modified: trunk/libdancer-perl/lib/Dancer/Serializer/Mutable.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Serializer/Mutable.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Serializer/Mutable.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Serializer/Mutable.pm Thu Jul 1 19:44:06 2010
@@ -28,23 +28,30 @@
$params = $request->params;
}
- if ( $request->{content_type} ) {
- $content_types{ $request->{content_type} } = 3;
+ my $method = $request->method;
+
+ if ($method =~ /^(?:POST|PUT)$/) {
+ if ($request->{content_type}) {
+ $content_types{$request->{content_type}} = 4;
+ }
+
+ if ($params && $params->{content_type}) {
+ $content_types{$params->{content_type}} = 3;
+ }
}
- if ( $params && $params->{content_type} ) {
- $content_types{ $params->{content_type} } = 2;
+ if ($request->{accept}) {
+ $content_types{$request->{accept}} = 2;
}
-
- if ( $request->{accept_type} ) {
- $content_types{ $request->{accept_type} } = 1;
+ if ($request->{'accept_type'}) {
+ $content_types{$request->{accept_type}} = 1;
}
$content_types{'application/json'} = 0;
return [
sort { $content_types{$b} <=> $content_types{$a} }
- keys %content_types
+ keys %content_types
];
}
@@ -116,7 +123,7 @@
=item
-the B<accept_type> from the request headers
+the B<accept> from the request headers
=item
Modified: trunk/libdancer-perl/lib/Dancer/Template/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/lib/Dancer/Template/Simple.pm?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/lib/Dancer/Template/Simple.pm (original)
+++ trunk/libdancer-perl/lib/Dancer/Template/Simple.pm Thu Jul 1 19:44:06 2010
@@ -34,64 +34,61 @@
my @buffer;
my $prefix = "";
my $should_bufferize = 1;
- my $opened_tag = 0;
my $bufferize_if_token = 0;
- $content =~ s/\Q${start}\E(\S)/${start} $1/sg;
- $content =~ s/(\S)\Q${stop}\E/$1 ${stop}/sg;
-
- foreach my $word (split / /, $content) {
- if ($word =~ /(.*)\Q$start\E/s) {
- my $junk = $1;
- $opened_tag = 1;
- if (defined($junk) && length($junk)) {
- $prefix = $junk;
- }
- }
- elsif ($word =~ /\Q$stop\E(.*)/s) {
- my $junk = $1;
- if (defined($junk) && length($junk)) {
- if (@buffer) {
- $buffer[$#buffer] .= $junk;
- }
- else {
- push @buffer, $junk;
- }
- }
- $opened_tag = 0;
- }
- elsif ($word eq 'if' && $opened_tag) {
- $bufferize_if_token = 1;
+# $content =~ s/\Q${start}\E(\S)/${start} $1/sg;
+# $content =~ s/(\S)\Q${stop}\E/$1 ${stop}/sg;
+
+ # we get here a list of tokens without the start/stop tags
+ my @full = split (/\Q$start\E\s*(.*?)\s*\Q$stop\E/, $content);
+
+ # and here a list of tokens without variables
+ my @flat = split (/\Q$start\E\s*.*?\s*\Q$stop\E/, $content);
+
+ # eg: for 'foo=<% var %>'
+ # @full = ('foo=', 'var')
+ # @flat = ('foo=')
+
+ my $flat_index = 0;
+ my $full_index = 0;
+ for my $word (@full) {
+
+ # flat word, nothing to do
+ if (defined $flat[$flat_index] && ($flat[$flat_index] eq $full[$full_index])) {
+ push @buffer, $word if $should_bufferize;
+ $flat_index++;
+ $full_index++;
next;
}
- elsif ($word eq 'else' && $opened_tag) {
- $should_bufferize = !$should_bufferize;
- next;
- }
- elsif ($word eq 'end' && $opened_tag) {
- $should_bufferize = 1;
- }
- elsif ($bufferize_if_token) {
- my $bool = _find_value_from_token_name($word, $tokens);
- $should_bufferize = _interpolate_value($bool) ? 1 : 0;
- $bufferize_if_token = 0;
- next;
- }
- elsif ($opened_tag) {
- push @buffer,
- ( $prefix
- . _interpolate_value(
- _find_value_from_token_name($word, $tokens)
- )
- );
- $prefix = "";
- }
- elsif ($should_bufferize) {
- push @buffer, $prefix . $word;
- $prefix = "";
- }
- }
-
- return join " ", @buffer;
+
+ my @to_parse = ($word);
+ @to_parse = split (/\s+/, $word) if $word =~ /\s+/;
+
+ for my $w (@to_parse) {
+
+ if ($w eq 'if') {
+ $bufferize_if_token = 1;
+ }
+ elsif ($w eq 'else') {
+ $should_bufferize = !$should_bufferize;
+ }
+ elsif ($w eq 'end') {
+ $should_bufferize = 1;
+ }
+ elsif ($bufferize_if_token) {
+ my $bool = _find_value_from_token_name($w, $tokens);
+ $should_bufferize = _interpolate_value($bool) ? 1 : 0;
+ $bufferize_if_token = 0;
+ }
+ elsif ($should_bufferize) {
+ my $val = _interpolate_value(_find_value_from_token_name($w, $tokens));
+ push @buffer, $val;
+ }
+ }
+
+ $full_index++;
+ }
+
+ return join "", @buffer;
}
# private
Modified: trunk/libdancer-perl/t/02_request/14_uploads.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/02_request/14_uploads.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/02_request/14_uploads.t (original)
+++ trunk/libdancer-perl/t/02_request/14_uploads.t Thu Jul 1 19:44:06 2010
@@ -11,7 +11,7 @@
is dirname($file), $dir, "dir of $file is $dir";
}
-plan tests => 11;
+plan tests => 13;
my $content = qq{------BOUNDARY
Content-Disposition: form-data; name="test_upload_file"; filename="yappo.txt"
@@ -87,5 +87,11 @@
ok $upload->file_handle, 'file handle is defined';
is $req->params->{'test_upload_file6'}, 'yappo6.txt',
"filename is accessible via params";
+
+ # make sure cleanup is performed when the HTTP::Body object is purged
+ my $file = $upload->tempname;
+ ok( (-f $file), 'temp file exists while HTTP::Body lives');
+ undef $req->{_http_body};
+ ok( (! -f $file), 'temp file is removed when HTTP::Body object dies');
};
Modified: trunk/libdancer-perl/t/02_request/15_headers.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/02_request/15_headers.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/02_request/15_headers.t (original)
+++ trunk/libdancer-perl/t/02_request/15_headers.t Thu Jul 1 19:44:06 2010
@@ -6,12 +6,17 @@
unless Dancer::ModuleLoader->load('LWP::UserAgent');
plan skip_all => 'Test::TCP is needed to run this test'
unless Dancer::ModuleLoader->load('Test::TCP');
-plan skip_all => 'Plack::Loader is needed to run this test'
- unless Dancer::ModuleLoader->load('Plack::Loader');
-plan tests => 6;
-for my $handler ('Standalone', 'PSGI') {
+my $plack_available = Dancer::ModuleLoader->load('Plack::Request');
+Dancer::ModuleLoader->load('Plack::Loader') if $plack_available;
+
+plan tests => $plack_available ? 6 : 3;
+
+my @handlers = ('Standalone');
+push @handlers, 'Plack' if $plack_available;
+
+for my $handler (@handlers) {
Test::TCP::test_tcp(
client => sub {
my $port = shift;
Modified: trunk/libdancer-perl/t/07_apphandlers/01_base.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/07_apphandlers/01_base.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/07_apphandlers/01_base.t (original)
+++ trunk/libdancer-perl/t/07_apphandlers/01_base.t Thu Jul 1 19:44:06 2010
@@ -1,7 +1,7 @@
use Test::More import => ['!pass'];
plan skip_all => "Plack is needed for this test"
- unless Dancer::ModuleLoader->load('Plack');
+ unless Dancer::ModuleLoader->load('Plack::Request');
plan tests => 4;
Modified: trunk/libdancer-perl/t/07_apphandlers/02_apache2_plack.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/07_apphandlers/02_apache2_plack.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/07_apphandlers/02_apache2_plack.t (original)
+++ trunk/libdancer-perl/t/07_apphandlers/02_apache2_plack.t Thu Jul 1 19:44:06 2010
@@ -5,7 +5,7 @@
use Test::More import => ['!pass'];
plan skip_all => "Plack is needed for this test"
- unless Dancer::ModuleLoader->load('Plack');
+ unless Dancer::ModuleLoader->load('Plack::Request');
plan tests => 2;
Modified: trunk/libdancer-perl/t/07_apphandlers/03_psgi_app.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/07_apphandlers/03_psgi_app.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/07_apphandlers/03_psgi_app.t (original)
+++ trunk/libdancer-perl/t/07_apphandlers/03_psgi_app.t Thu Jul 1 19:44:06 2010
@@ -5,11 +5,13 @@
use Dancer::ModuleLoader;
plan skip_all => "Plack is needed to run this test"
- unless Dancer::ModuleLoader->load('Plack::Loader');
+ unless Dancer::ModuleLoader->load('Plack::Request');
plan skip_all => "LWP is needed to run this test"
unless Dancer::ModuleLoader->load('LWP::UserAgent');
plan skip_all => "Test::TCP is needed to run this test"
unless Dancer::ModuleLoader->load('Test::TCP');
+
+Dancer::ModuleLoader->load('Plack::Loader');
my $app = sub {
my $env = shift;
Modified: trunk/libdancer-perl/t/10_template/03_simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/10_template/03_simple.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/10_template/03_simple.t (original)
+++ trunk/libdancer-perl/t/10_template/03_simple.t Thu Jul 1 19:44:06 2010
@@ -21,13 +21,13 @@
my $result = $engine->render(
$template,
- { var1 => 1,
- var2 => 2,
+ { var1 => "xxx",
+ var2 => "yyy",
foo => 'one',
bar => 'two',
baz => 'three'});
-my $expected = 'this is var1="1" and var2=2'."\n\nanother line\n\n one two three\n";
+my $expected = 'this is var1="xxx" and var2=yyy'."\n\nanother line\n\n one two three\n\nxxx/xxx\n";
is $result, $expected, "template got processed successfully";
# variable interpolation, with scalar-based template
@@ -72,8 +72,7 @@
is $result, $expected, "arrayref are interpolated in templates";
# if-then-else
-
-$template = '<% if want %> hello <% else %> goodbye <% end %> world';
+$template = '<% if want %>hello<% else %>goodbye<% end %> world';
$result = $engine->render(\$template, {want => 1});
is $result, 'hello world', "true boolean condition matched";
$result = $engine->render(\$template, {want => 0});
Modified: trunk/libdancer-perl/t/10_template/05_template_toolkit.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/10_template/05_template_toolkit.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/10_template/05_template_toolkit.t (original)
+++ trunk/libdancer-perl/t/10_template/05_template_toolkit.t Thu Jul 1 19:44:06 2010
@@ -39,7 +39,7 @@
bar => 'two',
baz => 'three'});
-my $expected = 'this is var1="1" and var2=2'."\n\nanother line\n\n one two three\n";
+my $expected = 'this is var1="1" and var2=2'."\n\nanother line\n\n one two three\n\n1/1\n";
is $result, $expected, "processed a template given as a file name";
$expected = "one=1, two=2, three=3";
Modified: trunk/libdancer-perl/t/10_template/index.txt
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/10_template/index.txt?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/10_template/index.txt (original)
+++ trunk/libdancer-perl/t/10_template/index.txt Thu Jul 1 19:44:06 2010
@@ -3,3 +3,5 @@
another line
<% foo%> <%bar %> <%baz%>
+
+<% var1 %>/<% var1 %>
Modified: trunk/libdancer-perl/t/14_serializer/05_live.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdancer-perl/t/14_serializer/05_live.t?rev=59959&op=diff
==============================================================================
--- trunk/libdancer-perl/t/14_serializer/05_live.t (original)
+++ trunk/libdancer-perl/t/14_serializer/05_live.t Thu Jul 1 19:44:06 2010
@@ -126,24 +126,26 @@
my $port = shift;
my $url = "http://127.0.0.1:$port/";
- my $req = HTTP::Request->new( GET => $url );
- $req->header( 'Content-Type' => 'application/json' );
+ for my $ct (qw/Accept Accept-Type/) {
+ my $req = HTTP::Request->new(GET => $url);
+ $req->header($ct => 'application/json');
+ my $ua = LWP::UserAgent->new;
+ my $res = $ua->request($req);
+ is_deeply(
+ JSON::decode_json($res->content),
+ {foo => 1},
+ "data is correctly serialized"
+ );
+ is $res->header('Content-Type'), 'application/json',
+ "content type is OK";
+ }
+
+ my $req = HTTP::Request->new( POST => $url );
+ $req->header('Content-Type' => 'text/x-yaml');
+ $req->header('Accept-Type' => 'application/json');
+ $req->content( YAML::Dump( { foo => 42 } ) );
my $ua = LWP::UserAgent->new;
my $res = $ua->request($req);
- is_deeply(
- JSON::decode_json( $res->content ),
- { foo => 1 },
- "data is correctly serialized"
- );
- is $res->header('Content-Type'), 'application/json',
- "content type is OK";
-
- undef $req;
- $req = HTTP::Request->new( POST => $url );
- $req->header( 'Content-Type' => 'text/x-yaml' );
- $req->content( YAML::Dump( { foo => 42 } ) );
- $ua = LWP::UserAgent->new;
- $res = $ua->request($req);
is_deeply(
YAML::Load( $res->content ),
{ foo => 42 },
More information about the Pkg-perl-cvs-commits
mailing list