Could some one point me to at what I'm doing wrong in the config.yml? I'm following the tutorial and the advent stuff and trying to enable plack_middlewares. Here's my config.yml layout: "main" charset: "UTF-8" template: "template_toolkit" engines: template_toolkit: encoding: 'utf8' start_tag: '[%' end_tag: '%]' log: 'debug' show_errors: 'true' plack_middlewares: Debug: - panels - - Memory - DBITrace - Timer Here's the error message when I plackup $ plackup -S Starman --workers=10 -p 5000 -a bin/app.pl Error while loading bin/app.pl: Unable to parse the configuration file: /opt/foobar/webapps/cemconf/config.yml: Died at /usr/local/share/perl/5.10.0/YAML/Loader.pm line 676, <$IN> line 1. at /usr/local/share/perl/5.10.0/Dancer/Config.pm line 177 Dancer::Config::load_settings_from_yaml('/opt/foobar/webapps/cemconf/config.yml') called at /usr/local/share/perl/5.10.0/Dancer/Config.pm line 159 Dancer::Config::load('Dancer::Config') called at /usr/local/share/perl/5.10.0/Dancer.pm line 225 Dancer::import('Dancer') called at bin/app.pl line 2 Plack::Sandbox::bin_2fapp_2epl::BEGIN() called at /usr/local/share/perl/5.10.0/Dancer.pm line 2 eval {...} called at /usr/local/share/perl/5.10.0/Dancer.pm line 2 require bin/app.pl called at (eval 8) line 3 eval 'package Plack::Sandbox::bin_2fapp_2epl; { my $app = do $_file; if ( !$app && ( my $error = $@ || $! )) { die $error; } $app; } ;' called at /usr/local/share/perl/5.10.0/Plack/Util.pm line 108 Plack::Util::_load_sandbox('bin/app.pl') called at /usr/local/share/perl/5.10.0/Plack/Util.pm line 124 Plack::Util::load_psgi('bin/app.pl') called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 173 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Loader.pm line 56 Plack::Loader::preload_app('Plack::Loader=HASH(0x91d2550)', 'CODE(0x93054e0)') called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 253 Plack::Runner::run('Plack::Runner=HASH(0x9119bf0)') called at /usr/local/bin/plackup line 10 BEGIN failed--compilation aborted at bin/app.pl line 2. Thanks for any help! ------------------------------ todd.bruner@gmail.com
On Monday 03 January 2011 23:32:35 Todd Bruner wrote:
Could some one point me to at what I'm doing wrong in the config.yml?
I'm following the tutorial and the advent stuff and trying to enable plack_middlewares.
Here's my config.yml
layout: "main" charset: "UTF-8" template: "template_toolkit" engines: template_toolkit: encoding: 'utf8' start_tag: '[%' end_tag: '%]' log: 'debug' show_errors: 'true' plack_middlewares: Debug: - panels - - Memory - DBITrace - Timer
Here's the error message when I plackup
<snipped> Looks like that error trace included lots of useless info, but not the pertinent info - the reason that the YAML wasn't parsed. Having dumped the above into a separate file, I tried the following: [davidp@supernova:~]$ perl -MYAML -e 'YAML::LoadFile "tmp/config.yml.todd";' YAML Error: Inconsistent indentation level Code: YAML_PARSE_ERR_INCONSISTENT_INDENTATION Line: 14 Document: 1 at /usr/local/share/perl/5.10.0/YAML.pm line 36 So, the answer is indeed that the YAML is not valid. Looking at it, I believe it's the following:
plack_middlewares: Debug: - panels - - Memory
The cookbook says this should be: plack_middlewares: - - Debug - panels - - DBITrace - Memory That's according to: http://search.cpan.org/~xsawyerx/Dancer-1.2003/lib/Dancer/Cookbook.pod#Plack... Can you give that a try, and let us know if that works? The comments in the example in the cookbook mention that "first element of the array is the name of the middleware, following elements are the configuration of the middleware". I do however think that syntax is ugly, and looks wrong to the eye. I'd much rather see, e.g.: plack_middlewares: Debug: panels: - Memory - DBITrace [etc] I suspect there's a good reason it wasn't done that way, though, but I don't have a chance to look in to it further right now. Cheers Dave P -- David Precious <davidp@preshweb.co.uk> http://blog.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/identica www.lyricsbadger.co.uk "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
I suspect there's a good reason it wasn't done that way, though, but I don't have a chance to look in to it further right now.
yup it's ugly, but middlewares need to be loaded in a specific order. You may want one middleware to be loaded before another one.
On Tue, Jan 4, 2011 at 9:39 AM, franck <franck@lumberjaph.net> wrote:
I suspect there's a good reason it wasn't done that way, though, but I don't have a chance to look in to it further right now.
[...] middlewares need to be loaded in a specific order. [...]
Proper composition. :)
OK. Found the problems: 1. was using tabs not spaces, 2. used example in Cookbook not what was below. Sorry for the false alarm... ------------------------------ todd.bruner@gmail.com On Mon, Jan 3, 2011 at 4:32 PM, Todd Bruner <todd.bruner@gmail.com> wrote:
Could some one point me to at what I'm doing wrong in the config.yml?
I'm following the tutorial and the advent stuff and trying to enable plack_middlewares.
Here's my config.yml
layout: "main" charset: "UTF-8" template: "template_toolkit" engines: template_toolkit: encoding: 'utf8' start_tag: '[%' end_tag: '%]' log: 'debug' show_errors: 'true' plack_middlewares: Debug: - panels - - Memory - DBITrace - Timer
Here's the error message when I plackup
$ plackup -S Starman --workers=10 -p 5000 -a bin/app.pl Error while loading bin/app.pl: Unable to parse the configuration file: /opt/foobar/webapps/cemconf/config.yml: Died at /usr/local/share/perl/5.10.0/YAML/Loader.pm line 676, <$IN> line 1. at /usr/local/share/perl/5.10.0/Dancer/Config.pm line 177 Dancer::Config::load_settings_from_yaml('/opt/foobar/webapps/cemconf/config.yml') called at /usr/local/share/perl/5.10.0/Dancer/Config.pm line 159 Dancer::Config::load('Dancer::Config') called at /usr/local/share/perl/5.10.0/Dancer.pm line 225 Dancer::import('Dancer') called at bin/app.pl line 2 Plack::Sandbox::bin_2fapp_2epl::BEGIN() called at /usr/local/share/perl/5.10.0/Dancer.pm line 2 eval {...} called at /usr/local/share/perl/5.10.0/Dancer.pm line 2 require bin/app.pl called at (eval 8) line 3 eval 'package Plack::Sandbox::bin_2fapp_2epl; { my $app = do $_file; if ( !$app && ( my $error = $@ || $! )) { die $error; } $app; }
;' called at /usr/local/share/perl/5.10.0/Plack/Util.pm line 108 Plack::Util::_load_sandbox('bin/app.pl') called at /usr/local/share/perl/5.10.0/Plack/Util.pm line 124 Plack::Util::load_psgi('bin/app.pl') called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 173 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 23 Plack::Runner::__ANON__() called at /usr/local/share/perl/5.10.0/Plack/Loader.pm line 56 Plack::Loader::preload_app('Plack::Loader=HASH(0x91d2550)', 'CODE(0x93054e0)') called at /usr/local/share/perl/5.10.0/Plack/Runner.pm line 253 Plack::Runner::run('Plack::Runner=HASH(0x9119bf0)') called at /usr/local/bin/plackup line 10 BEGIN failed--compilation aborted at bin/app.pl line 2.
Thanks for any help! ------------------------------ todd.bruner@gmail.com
participants (4)
-
David Precious -
franck -
sawyer x -
Todd Bruner