From andy at andybev.com Tue Jul 7 22:58:57 2015 From: andy at andybev.com (Andrew Beverley) Date: Tue, 07 Jul 2015 22:58:57 +0100 Subject: [dancer-users] Dancer and forking Message-ID: <1436306337.8826.20.camel@andybev.com> Dear all, Is there anything that I should be aware of if using fork() in a dancer application? I have some cache update code which can take a while to run, so I'd rather do it in the background. I've therefore done something like this: post '/data' => sub { my $template = ...; fork and return $template; update_cache; exit; } The actual code is in a module, but you get the idea. Thanks, Andy From johandry at gmail.com Wed Jul 8 00:58:06 2015 From: johandry at gmail.com (Johandry Amador Segui) Date: Tue, 7 Jul 2015 16:58:06 -0700 Subject: [dancer-users] Dancer and forking In-Reply-To: <1436306337.8826.20.camel@andybev.com> References: <1436306337.8826.20.camel@andybev.com> Message-ID: <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> Hi Andy, I tried to use threads and it did not worked for me (maybe because of non safe thread modules I am using) so I use fork in a production application and it works good. I have some issues some times with MySQL that I have not fixed yet but they do not happen very often. This is an example of how I use it: sub execute { # These 2 lines below were to eliminate the error that I mentioned before. It did not eliminated them just reduce them my $dbh = database(); $dbh->{InactiveDestroy} = 1; my $pid = fork(); if ($pid) { # This is the parent (Dancer) in case you want to do something here debug ?Process started with PID $pid\n?; } elsif ($pid == 0) { # This is the child, here is where I do all I need $template = ... } else { debug ?Could not fork: $!\n?; } # I have a variable to know if I?m running this sub from the web or from CLI if ($cli) { my $output = waitpid($pid, 0); print ?The process finish with output: $output?; } return $template; } This is just an example, not the entire code. If someone has a suggestion or improvement, it is welcome. Thanks, Johandry > On Jul 7, 2015, at 2:58 PM, Andrew Beverley wrote: > > Dear all, > > Is there anything that I should be aware of if using fork() in a dancer > application? > > I have some cache update code which can take a while to run, so I'd rather do it > in the background. I've therefore done something like this: > > post '/data' => sub { > my $template = ...; > fork and return $template; > update_cache; > exit; > } > > The actual code is in a module, but you get the idea. > > Thanks, > > Andy > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users From andy at andybev.com Wed Jul 8 07:15:29 2015 From: andy at andybev.com (Andrew Beverley) Date: Wed, 08 Jul 2015 07:15:29 +0100 Subject: [dancer-users] Dancer and forking In-Reply-To: <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> References: <1436306337.8826.20.camel@andybev.com> <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> Message-ID: <47f38d501b2bb9239c52a45080affd40@andybev.com> On 2015-07-08 00:58, Johandry Amador Segui wrote: > Hi Andy, > > I tried to use threads and it did not worked for me (maybe because of > non safe thread modules I am using) so I use fork in a production > application and it works good. I have some issues some times with > MySQL that I have not fixed yet but they do not happen very often. > > This is an example of how I use it: > > sub execute { > > # These 2 lines below were to eliminate the error that I mentioned > before. It did not eliminated them just reduce them > my $dbh = database(); > $dbh->{InactiveDestroy} = 1; > > my $pid = fork(); > > if ($pid) { > # This is the parent (Dancer) in case you want to do something here > debug ?Process started with PID $pid\n?; > > } elsif ($pid == 0) { > # This is the child, here is where I do all I need > $template = ... > } else { > debug ?Could not fork: $!\n?; > } > > # I have a variable to know if I?m running this sub from the web or > from CLI > if ($cli) { > my $output = waitpid($pid, 0); > print ?The process finish with output: $output?; > } > > return $template; > } > > This is just an example, not the entire code. If someone has a > suggestion or improvement, it is welcome. Surely you need an exit() in there somewhere for the child process, otherwise you'll end up with lots of web server threads? Andy From xsawyerx at gmail.com Wed Jul 8 13:56:34 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Wed, 8 Jul 2015 14:56:34 +0200 Subject: [dancer-users] Dancer and forking In-Reply-To: <47f38d501b2bb9239c52a45080affd40@andybev.com> References: <1436306337.8826.20.camel@andybev.com> <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> <47f38d501b2bb9239c52a45080affd40@andybev.com> Message-ID: Any chance one of you would like to write a short article about it for the Advent Calendar of 2016? :) On Wed, Jul 8, 2015 at 8:15 AM, Andrew Beverley wrote: > On 2015-07-08 00:58, Johandry Amador Segui wrote: > >> Hi Andy, >> >> I tried to use threads and it did not worked for me (maybe because of >> non safe thread modules I am using) so I use fork in a production >> application and it works good. I have some issues some times with >> MySQL that I have not fixed yet but they do not happen very often. >> >> This is an example of how I use it: >> >> sub execute { >> >> # These 2 lines below were to eliminate the error that I mentioned >> before. It did not eliminated them just reduce them >> my $dbh = database(); >> $dbh->{InactiveDestroy} = 1; >> >> my $pid = fork(); >> >> if ($pid) { >> # This is the parent (Dancer) in case you want to do >> something here >> debug ?Process started with PID $pid\n?; >> >> } elsif ($pid == 0) { >> # This is the child, here is where I do all I need >> $template = ... >> } else { >> debug ?Could not fork: $!\n?; >> } >> >> # I have a variable to know if I?m running this sub from the web >> or from CLI >> if ($cli) { >> my $output = waitpid($pid, 0); >> print ?The process finish with output: $output?; >> } >> >> return $template; >> } >> >> This is just an example, not the entire code. If someone has a >> suggestion or improvement, it is welcome. >> > > Surely you need an exit() in there somewhere for the child process, > otherwise you'll end up with lots of web server threads? > > > Andy > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From xsawyerx at gmail.com Wed Jul 8 14:15:06 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Wed, 8 Jul 2015 15:15:06 +0200 Subject: [dancer-users] Dancer2 v0.161000 on its way to CPAN Message-ID: Hi everyone, A new version of Dancer2 is on its way to CPAN as we speak. It has a lot of exciting changes that I want to share with you. First of all, it's significantly faster, since the request object is now fully based on Plack::Request. I'm very proud of that. There are still additional spots we want to improve (I'm looking at you, parameters!) and we have room for further optimizations (in fact there's a branch waiting for merging that optimizes it even further), but it's at a much better standing as of this release. Security has improved thanks to work by Andy Beverley (thanks!) and Russell Jenkins (G'day!). Thanks goes to long-time community member, Pedro Melo! The build and install time for Dancer2 has now been substantially improved. We removed unnecessary dependencies (prompted by David Golden!) and no longer require memory cycle tests (unless you have it installed) or Module::Build, since we already support MakeMaker. We now handle a long-standing issue of sending non-hash data. JSON (and other serializers) allow you to serialize arrays or strings but parameters don't work that way. Until now that would crash (and get caught by Dancer, of course, but still annoying), whereas now it silently ignores them for the parameters, but still makes them available via "request->data". An additional "VERSION" method fix, thanks to Miyagawa for reporting! The old dispatcher which goes into effect when you call the "dance" method (although we recommend "to_app" instead) had a small bug fix provided. Changelog with ticket numbers is included below. A big thanks to everyone involved with this release and this lovely community. >From the Dancer core dev team with love, Sawyer. 0.161000 2015-07-08 14:57:16+02:00 Europe/Amsterdam [ BUG FIXES ] * GH #915, #930: Check existence of optional extension headers when behind proxy. (Andy Beverley, Pedro Melo, Russell Jenkins) * GH #926, #940: Set session directory default to $apprdir/session. (Russell Jenkins) * GH #936, #939: Use the error_template configuration on a 404. (Russell Jenkins) * GH #844, #937: Non-hash serialized params do not cause a crash. (Sawyer X) * GH #943: Pass @_ to UNIVERSAL's VERSION so it validates version number. (Sawyer X) * GH #934: Cleanup internals in the old Dispatcher. (Russell Jenkins) [ DOCUMENTATION ] * Sanitize Changes * GH #938: Fix POD link to params keyword. (Ludovic Tolhurst-Cleaver) * GH #935: Provide more details and considerations when using behind_proxy. (Andy Beverley) [ ENHANCEMENT ] * GH #933: use note in tests to produce cleaner non-verbose output (Vernon) * Remove unnecessary dependencies: build chain should be smaller. (Sawyer X) * No need for Module::Build. (Sawyer X) * GH #911: Dancer2 request object is now a subclass of Plack::Request. It's also much faster now. (Sawyer X) From andy at andybev.com Wed Jul 8 14:49:43 2015 From: andy at andybev.com (Andrew Beverley) Date: Wed, 08 Jul 2015 14:49:43 +0100 Subject: [dancer-users] Dancer and forking In-Reply-To: References: <1436306337.8826.20.camel@andybev.com> <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> <47f38d501b2bb9239c52a45080affd40@andybev.com> Message-ID: <1436363383.13907.8.camel@andybev.com> On Wed, 2015-07-08 at 14:56 +0200, Sawyer X wrote: > Any chance one of you would like to write a short article about it for the > Advent Calendar of 2016? :) Of course, no problem at all. I was actually concerned that what I was doing might be wrong/bad in some way, hence the post, but if it's fine and worth sharing then very happy! I'd also be happy to write something up about logging (regarding Plugin::LogReport which I'll post about here once some changes have been made), and the Plugin::Auth::Extensible changes that allow password resets etc. Andy From xsawyerx at gmail.com Wed Jul 8 19:11:15 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Wed, 8 Jul 2015 20:11:15 +0200 Subject: [dancer-users] Dancer and forking In-Reply-To: <1436363383.13907.8.camel@andybev.com> References: <1436306337.8826.20.camel@andybev.com> <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> <47f38d501b2bb9239c52a45080affd40@andybev.com> <1436363383.13907.8.camel@andybev.com> Message-ID: That would be great! On Wed, Jul 8, 2015 at 3:49 PM, Andrew Beverley wrote: > On Wed, 2015-07-08 at 14:56 +0200, Sawyer X wrote: > > Any chance one of you would like to write a short article about it for > the > > Advent Calendar of 2016? :) > > Of course, no problem at all. I was actually concerned that what I was > doing might > be wrong/bad in some way, hence the post, but if it's fine and worth > sharing then > very happy! > > I'd also be happy to write something up about logging (regarding > Plugin::LogReport > which I'll post about here once some changes have been made), and the > Plugin::Auth::Extensible changes that allow password resets etc. > > Andy > > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johandry at gmail.com Wed Jul 8 21:59:30 2015 From: johandry at gmail.com (Johandry Amador Segui) Date: Wed, 8 Jul 2015 13:59:30 -0700 Subject: [dancer-users] Dancer and forking In-Reply-To: <47f38d501b2bb9239c52a45080affd40@andybev.com> References: <1436306337.8826.20.camel@andybev.com> <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> <47f38d501b2bb9239c52a45080affd40@andybev.com> Message-ID: <12783037-5088-4AD5-858E-54F0B5E44833@gmail.com> Exactly, I have it. I highlighted in red the exit from the child. Also (maybe is useful) I have a print with an ?if $cli? to print messages in the console (debugging or logging) when the sub is executed from the CLI. use POSIX qw(_exit); sub execute { # These 2 lines below were to eliminate the error that I mentioned before. It did not eliminated them just reduce them my $dbh = database(); $dbh->{InactiveDestroy} = 1; my $pid = fork(); if ($pid) { # This is the parent (Dancer) in case you want to do something here debug ?Process started with PID $pid\n?; } elsif ($pid == 0) { # This is the child, here is where I do all I need $template = ? $exit_code= ? print ?Something in the console? if $cli _exit($exit_code); } else { debug ?Could not fork: $!\n?; } # I have a variable to know if I?m running this sub from the web or from CLI if ($cli) { my $output = waitpid($pid, 0); print ?The process finish with output: $output?; } return $template; } > On Jul 7, 2015, at 11:15 PM, Andrew Beverley wrote: > > On 2015-07-08 00:58, Johandry Amador Segui wrote: >> Hi Andy, >> I tried to use threads and it did not worked for me (maybe because of >> non safe thread modules I am using) so I use fork in a production >> application and it works good. I have some issues some times with >> MySQL that I have not fixed yet but they do not happen very often. >> This is an example of how I use it: >> sub execute { >> # These 2 lines below were to eliminate the error that I mentioned >> before. It did not eliminated them just reduce them >> my $dbh = database(); >> $dbh->{InactiveDestroy} = 1; >> my $pid = fork(); >> if ($pid) { >> # This is the parent (Dancer) in case you want to do something here >> debug ?Process started with PID $pid\n?; >> } elsif ($pid == 0) { >> # This is the child, here is where I do all I need >> $template = ... >> } else { >> debug ?Could not fork: $!\n?; >> } >> # I have a variable to know if I?m running this sub from the web or from CLI >> if ($cli) { >> my $output = waitpid($pid, 0); >> print ?The process finish with output: $output?; >> } >> return $template; >> } >> This is just an example, not the entire code. If someone has a >> suggestion or improvement, it is welcome. > > Surely you need an exit() in there somewhere for the child process, otherwise you'll end up with lots of web server threads? > > Andy > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From xsawyerx at gmail.com Fri Jul 10 07:38:08 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Fri, 10 Jul 2015 08:38:08 +0200 Subject: [dancer-users] Dancer and forking In-Reply-To: <12783037-5088-4AD5-858E-54F0B5E44833@gmail.com> References: <1436306337.8826.20.camel@andybev.com> <4A8A0F64-9133-45F4-8EA9-F298D94A7BB6@gmail.com> <47f38d501b2bb9239c52a45080affd40@andybev.com> <12783037-5088-4AD5-858E-54F0B5E44833@gmail.com> Message-ID: If it's CLI, can't you just set up the Console logger? You wouldn't need the if() there, only at a setup() method. On Wed, Jul 8, 2015 at 10:59 PM, Johandry Amador Segui wrote: > Exactly, I have it. I highlighted in red the exit from the child. > > Also (maybe is useful) I have a print with an ?if $cli? to print messages > in the console (debugging or logging) when the sub is executed from the CLI. > > use POSIX qw(_exit); > > sub execute { > > # These 2 lines below were to eliminate the error that I mentioned before. > It did not eliminated them just reduce them > my $dbh = database(); > $dbh->{InactiveDestroy} = 1; > > my $pid = fork(); > > if ($pid) { > # This is the parent (Dancer) in case you want to do something here > debug ?Process started with PID $pid\n?; > > } elsif ($pid == 0) { > # This is the child, here is where I do all I need > $template = ? > $exit_code= ? > > print ?Something in the console? if $cli > _exit($exit_code); > } else { > debug ?Could not fork: $!\n?; > } > > # I have a variable to know if I?m running this sub from the web or from > CLI > if ($cli) { > my $output = waitpid($pid, 0); > print ?The process finish with output: $output?; > } > > return $template; > } > > > On Jul 7, 2015, at 11:15 PM, Andrew Beverley wrote: > > On 2015-07-08 00:58, Johandry Amador Segui wrote: > > Hi Andy, > I tried to use threads and it did not worked for me (maybe because of > non safe thread modules I am using) so I use fork in a production > application and it works good. I have some issues some times with > MySQL that I have not fixed yet but they do not happen very often. > This is an example of how I use it: > sub execute { > # These 2 lines below were to eliminate the error that I mentioned > before. It did not eliminated them just reduce them > my $dbh = database(); > $dbh->{InactiveDestroy} = 1; > my $pid = fork(); > if ($pid) { > # This is the parent (Dancer) in case you want to do something here > debug ?Process started with PID $pid\n?; > } elsif ($pid == 0) { > # This is the child, here is where I do all I need > $template = ... > } else { > debug ?Could not fork: $!\n?; > } > # I have a variable to know if I?m running this sub from the web or from > CLI > if ($cli) { > my $output = waitpid($pid, 0); > print ?The process finish with output: $output?; > } > return $template; > } > This is just an example, not the entire code. If someone has a > suggestion or improvement, it is welcome. > > > Surely you need an exit() in there somewhere for the child process, > otherwise you'll end up with lots of web server threads? > > Andy > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom.browder at gmail.com Thu Jul 16 12:39:46 2015 From: tom.browder at gmail.com (Tom Browder) Date: Thu, 16 Jul 2015 06:39:46 -0500 Subject: [dancer-users] Adding dancer2 to an existing web site. Message-ID: I have a web site with primarily static content and a few Perl CGI scripts. 1. Can I start integrating dancer2 a bit at a time without a wholesale site rewrite? 2. What is recommended as the best way to deploy dancer2 under Apache 2.4? Thanks. Best regards, -Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From clive at hildebrand.co.uk Thu Jul 16 12:55:58 2015 From: clive at hildebrand.co.uk (Clive Eisen) Date: Thu, 16 Jul 2015 12:55:58 +0100 Subject: [dancer-users] Adding dancer2 to an existing web site. In-Reply-To: References: Message-ID: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> > On 16 Jul 2015, at 12:39, Tom Browder wrote: > > I have a web site with primarily static content and a few Perl CGI scripts. > > 1. Can I start integrating dancer2 a bit at a time without a wholesale site rewrite? Yep > > 2. What is recommended as the best way to deploy dancer2 under Apache 2.4? > Run Dancer under starman or whatever proxy from apache to starman one call at a time as you are happy with it When all done - remove apache and use nginx as the proxy ;-) ? Clive -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 495 bytes Desc: Message signed with OpenPGP using GPGMail URL: From tom.browder at gmail.com Thu Jul 16 14:05:02 2015 From: tom.browder at gmail.com (Tom Browder) Date: Thu, 16 Jul 2015 08:05:02 -0500 Subject: [dancer-users] Adding dancer2 to an existing web site. In-Reply-To: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> References: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> Message-ID: On Jul 16, 2015 6:56 AM, "Clive Eisen" wrote: > > 2. What is recommended as the best way to deploy dancer2 under > > Apache 2.4? > > > Run Dancer under starman or whatever > > proxy from apache to starman one call at a time as you are happy with it > When all done - remove apache and use nginx as the proxy ;-) Hm, I have a lot invested in my Apache configuration, and I love its virtual host handling. I tried nginx some time ago and I'm not sure it can do all I need to do with client certificate handling (and the docs left a lot to be desired). But I'm open to a rethink. Thanks, Clive. Best regards, -Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at andybev.com Thu Jul 16 14:57:17 2015 From: andy at andybev.com (Andrew Beverley) Date: Thu, 16 Jul 2015 14:57:17 +0100 Subject: [dancer-users] Adding dancer2 to an existing web site. In-Reply-To: References: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> Message-ID: <1437055037.23961.9.camel@andybev.com> On Thu, 2015-07-16 at 08:05 -0500, Tom Browder wrote: > On Jul 16, 2015 6:56 AM, "Clive Eisen" wrote: > > > 2. What is recommended as the best way to deploy dancer2 under > > > Apache 2.4? > > > > > Run Dancer under starman or whatever > > > > proxy from apache to starman one call at a time as you are happy with it > > When all done - remove apache and use nginx as the proxy ;-) > > Hm, I have a lot invested in my Apache configuration, and I love its > virtual host handling. I tried nginx some time ago and I'm not sure it can > do all I need to do with client certificate handling (and the docs left a > lot to be desired). But I'm open to a rethink. The easiest way to use Dancer with Apache is via FastCGI: https://metacpan.org/pod/Dancer::Deployment#Running-as-a-cgi-script-or-fast-cgi -under-Apache Note that for 2.4 you will need: Require all granted Instead of: Order allow,deny Allow from all There are some occasions when you might want to use Apache as a proxy to Starman instead, but for most use-cases FastCGI is easier and quicker. MST has a good little blog about deploying web apps in general: http://shadow.cat/blog/matt-s-trout/mstpan-2/ Andy From tom.browder at gmail.com Thu Jul 16 15:37:46 2015 From: tom.browder at gmail.com (Tom Browder) Date: Thu, 16 Jul 2015 09:37:46 -0500 Subject: [dancer-users] Adding dancer2 to an existing web site. In-Reply-To: <1437055037.23961.9.camel@andybev.com> References: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> <1437055037.23961.9.camel@andybev.com> Message-ID: On Jul 16, 2015 8:57 AM, "Andrew Beverley" wrote: > On Thu, 2015-07-16 at 08:05 -0500, Tom Browder wrote: > > On Jul 16, 2015 6:56 AM, "Clive Eisen" wrote: > > > > 2. What is recommended as the best way to deploy dancer2 under > > > > Apache 2.4? ... > The easiest way to use Dancer with Apache is via FastCG: ... Thanks for some good advice, Andy! Best regards, -Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From hvo.pm at xs4all.nl Thu Jul 16 15:58:31 2015 From: hvo.pm at xs4all.nl (hvo.pm at xs4all.nl) Date: Thu, 16 Jul 2015 16:58:31 +0200 (CEST) Subject: [dancer-users] Adding dancer2 to an existing web site. In-Reply-To: <1437055037.23961.9.camel@andybev.com> References: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> <1437055037.23961.9.camel@andybev.com> Message-ID: On Thu, 16 Jul 2015, Andrew Beverley wrote: > The easiest way to use Dancer with Apache is via FastCGI: > > https://metacpan.org/pod/Dancer::Deployment#Running-as-a-cgi-script-or-fast-cgi That link points to the RewriteEngine version. I use: ScriptAlias /myapp /path/to/myapp/bin/dispatch.fcgi Note: - dispatch.fcgi is NOT in the document root - Do NOT detach -- in dispatch.fcgi -- my $server = Plack::Handler::FCGI->new(nproc => 1, detach => 0); - Running the same code as stand-alone for testing needs some tweeks I have a scriptalias in my config.yml scriptalias: "/myapp" and a plugin that exports the DSL keyword scriptalias Loading sub-apps like this: if (setting('environment') eq 'production') { load_app 'Subapp', prefix => '/subapp'; } else { load_app 'Subapp', prefix => scriptalias . '/subapp'; } Mmm, maybe overkill... setting some $scriptalias can construct a prefix "$scriptalias/subapp" Running 'perl bin/app.pl' just works. One can use this to slowly convert /cgi-bin/subapp1.pl /cgi-bin/subapp2.pl to /myapp/subapp1 /myapp/subapp2 HTH, Henk From tom.browder at gmail.com Thu Jul 16 16:18:10 2015 From: tom.browder at gmail.com (Tom Browder) Date: Thu, 16 Jul 2015 10:18:10 -0500 Subject: [dancer-users] Adding dancer2 to an existing web site. In-Reply-To: References: <1391C424-F42F-4E18-BB3C-29EA8E660E96@hildebrand.co.uk> <1437055037.23961.9.camel@andybev.com> Message-ID: Thanks, Henk! Best regards, -Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From ml at felicis.net Fri Jul 17 02:08:20 2015 From: ml at felicis.net (Vincent Freeman) Date: Thu, 16 Jul 2015 21:08:20 -0400 Subject: [dancer-users] Examining incoming POST headers. Message-ID: <20150716210820.a610ee47f8acac572293edaa@felicis.net> Hi guys, I'm new to Dancer2 and I'm trying to access an authorization header, similar to Github's 'X-Hub-Signature'. I consulted with https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header,it says to use 'headers' to "Adds custom headers to responses" and 'header' to "adds a custom header to response", but it does not say how to retrieve the header information, rather than adding it. I'm using starman with nginx as the forward proxy. This is my code for testing header access: post '//hook' => sub { my $hd = header "Content-Type";; "Your Headers: [".$hd."]"; }; When I issue a curl, it returns empty. What am I doing wrong? Feedback welcomed and thanked in advance. Cheers, Vince. From ZahirLalani at oliver.agency Fri Jul 10 11:39:20 2015 From: ZahirLalani at oliver.agency (Zahir Lalani) Date: Fri, 10 Jul 2015 10:39:20 +0000 Subject: [dancer-users] JSON Serialiser Message-ID: Hi All Just came across this previous message whilst debugging an issue: John Barrett john at jbrt.org Thu Apr 16 10:25:03 BST 2015 * Previous message: [dancer-users] JSON serializer, returning object instances form route handlers, convert_blessed * Next message: [dancer-users] Dancer training at YAPC::NA * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] ________________________________ On Wed, 15 Apr 2015 17:55:11 +0100 John Barrett > wrote: > > get '/object' => sub { > AnObject->new; > }; > Quick follow up on this, Wrapping the instance in a hashref constructor performs as expected: get '/object' => sub { { object => AnObject->new }; }; ...which I guess is what I should have been doing in the first place. Sorry for noise. There was no confirmation of the final message. I have the exact same issue - the return of an object used to work fine - the code I have was tested 2 months ago with no issues. We have of course been updating modules and dancer, and coming back to this project, the serialiser now gives the Route Exception error just like for John. I will test out his solution - can I get confirmation that this is indeed the way to properly handle it, or is this a bug? Zahir Lalani Head of Development & Architecture [cid:96F784CA-E917-4CC1-A9A9-96CBDA2AF2BC] 2 Tabernacle Street, London, EC2A 4LU m: +44 (0)7956 455168 t: +44 (0)203 142 3619 e: zahirlalani at oliver-marketing.com w: www.oliver-marketing.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 2166 bytes Desc: image001.png URL: From racke at linuxia.de Fri Jul 17 14:56:38 2015 From: racke at linuxia.de (Stefan Hornburg (Racke)) Date: Fri, 17 Jul 2015 15:56:38 +0200 Subject: [dancer-users] Perl Dancer Conference 2015 - Call for Papers Message-ID: <55A90996.7050608@linuxia.de> The Call for Papers for the Perl Dancer Conference 2015 in Vienna is now open! We are accepting presentations in a wide range of topics, for example Dancer, Modern Perl, DBIx::Class, Perl "products" and security. Of course, we are open for any idea and submission. The submission deadline is August 31th, midnight CET. Talks are reviewed and possibly accepted as we receive them. Please use the online form at http://www.perl.dance/talks/submit for submitting your presentation. If you are not going to present at the conference, please spread the word. Regards Racke -- Perl and Dancer Development Visit our Perl::Dancer conference 2015. More information on http://www.perl.dance. From naveed at vt.edu Sat Jul 18 06:35:44 2015 From: naveed at vt.edu (Naveed Massjouni) Date: Sat, 18 Jul 2015 01:35:44 -0400 Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: <20150716210820.a610ee47f8acac572293edaa@felicis.net> References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> Message-ID: On Thu, Jul 16, 2015 at 9:08 PM, Vincent Freeman wrote: > > Hi guys, > > I'm new to Dancer2 and I'm trying to access an authorization header, similar to Github's 'X-Hub-Signature'. > > I consulted with https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header,it says to use 'headers' to "Adds custom headers to responses" and 'header' to "adds a custom header to response", but it does not say how to retrieve the header information, rather than adding it. > > I'm using starman with nginx as the forward proxy. > > This is my code for testing header access: > > post '//hook' => sub { > my $hd = header "Content-Type";; > "Your Headers: [".$hd."]"; > }; The header keyword is for setting a header. I think you want: my $hd = request->header('Content-Type'); See: https://metacpan.org/pod/Dancer2::Core::Request -Naveed Massjouni > > When I issue a curl, it returns empty. > > What am I doing wrong? > > Feedback welcomed and thanked in advance. > > Cheers, > > Vince. > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users From lennart at farenji.net Fri Jul 17 08:44:25 2015 From: lennart at farenji.net (Lennart Hengstmengel) Date: Fri, 17 Jul 2015 09:44:25 +0200 Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: <20150716210820.a610ee47f8acac572293edaa@felicis.net> References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> Message-ID: <55A8B259.7050400@farenji.net> Hi Vince, Try: my $headercontent = request->header('Your-Header-Here'); Kind regards, Lennart On 17-07-15 03:08, Vincent Freeman wrote: > Hi guys, > > I'm new to Dancer2 and I'm trying to access an authorization header, similar to Github's 'X-Hub-Signature'. > > I consulted with https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header,it says to use 'headers' to "Adds custom headers to responses" and 'header' to "adds a custom header to response", but it does not say how to retrieve the header information, rather than adding it. > > I'm using starman with nginx as the forward proxy. > > This is my code for testing header access: > > post '//hook' => sub { > my $hd = header "Content-Type";; > "Your Headers: [".$hd."]"; > }; > > When I issue a curl, it returns empty. > > What am I doing wrong? > > Feedback welcomed and thanked in advance. > > Cheers, > > Vince. > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > From xsawyerx at gmail.com Sun Jul 19 00:30:52 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Sun, 19 Jul 2015 01:30:52 +0200 Subject: [dancer-users] JSON Serialiser In-Reply-To: References: Message-ID: I don't understand this email. T abundance of HTML in your message is quite disruptive. You either did not include the actual error or the HTML is in the way. I'm not even sure what I'm reading, but it seems like you copy pasted your inbox and a message you received and a comment to that message. I'm not sure. Also, other than not including the error, you didn't really provide any context to this. What is this about? What would help is "this is my code and here is an error I received". Both are not present. :) Can you please fill in the blanks? On Fri, Jul 10, 2015 at 12:39 PM, Zahir Lalani wrote: > Hi All > > > > Just came across this previous message whilst debugging an issue: > > > > *John Barrett* john at jbrt.org > > *Thu Apr 16 10:25:03 BST 2015* > > - Previous message: [dancer-users] JSON serializer, returning object > instances form route handlers, convert_blessed > > - Next message: [dancer-users] Dancer training at YAPC::NA > > - *Messages sorted by:* [ date ] > > [ thread ] > > [ subject ] > > [ author ] > > > ------------------------------ > > On Wed, 15 Apr 2015 17:55:11 +0100 > > John Barrett > wrote: > > > > > > > >* get '/object' => sub {* > > >* AnObject->new;* > > >* };* > > > > > > > Quick follow up on this, > > > > Wrapping the instance in a hashref constructor performs as expected: > > > > get '/object' => sub { > > { object => AnObject->new }; > > }; > > > > ...which I guess is what I should have been doing in the first place. > > > > Sorry for noise. > > > > > > There was no confirmation of the final message. I have the exact same > issue ? the return of an object used to work fine ? the code I have was > tested 2 months ago with no issues. We have of course been updating modules > and dancer, and coming back to this project, the serialiser now gives the > Route Exception error just like for John. I will test out his solution ? > can I get confirmation that this is indeed the way to properly handle it, > or is this a bug? > > > > > > > > > *Zahir Lalani Head of Development & Architecture* > > [image: cid:96F784CA-E917-4CC1-A9A9-96CBDA2AF2BC] > > 2 Tabernacle Street, > > London, EC2A 4LU > > > > m: +44 (0)7956 455168 > > t: +44 (0)203 142 3619 > > e: *zahirlalani at oliver-marketing.com * > > w: www.oliver-marketing.com > > > > > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 2166 bytes Desc: not available URL: From xsawyerx at gmail.com Sun Jul 19 00:35:52 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Sun, 19 Jul 2015 01:35:52 +0200 Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: <55A8B259.7050400@farenji.net> References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> <55A8B259.7050400@farenji.net> Message-ID: The DSL keywords are much more preferable since that allows us to play more with the internals. We assure the DSL will work, but we do not assure the internal objects will stay the same. In this specific case, I see no reason why "request->headers" won't work forever. It seems like "headers" is only calling "header" again instead of literally calling the "headers". Vincent, would you be able to raise this as a ticket meanwhile so we could address it and you could easily track it? On Fri, Jul 17, 2015 at 9:44 AM, Lennart Hengstmengel wrote: > Hi Vince, > > Try: > > my $headercontent = request->header('Your-Header-Here'); > > > Kind regards, > Lennart > > > On 17-07-15 03:08, Vincent Freeman wrote: > >> Hi guys, >> >> I'm new to Dancer2 and I'm trying to access an authorization header, >> similar to Github's 'X-Hub-Signature'. >> >> I consulted with >> https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header,it >> says to use 'headers' to "Adds custom headers to responses" and 'header' to >> "adds a custom header to response", but it does not say how to retrieve the >> header information, rather than adding it. >> >> I'm using starman with nginx as the forward proxy. >> >> This is my code for testing header access: >> >> post '//hook' => sub { >> my $hd = header "Content-Type";; >> "Your Headers: [".$hd."]"; >> }; >> When I issue a curl, it returns empty. >> >> What am I doing wrong? >> >> Feedback welcomed and thanked in advance. >> >> Cheers, >> >> Vince. >> _______________________________________________ >> dancer-users mailing list >> dancer-users at dancer.pm >> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ml at felicis.net Sun Jul 19 03:28:45 2015 From: ml at felicis.net (Vincent Freeman) Date: Sat, 18 Jul 2015 22:28:45 -0400 Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> <55A8B259.7050400@farenji.net> Message-ID: <20150718222845.3d969714ca39e35be6d89603@felicis.net> [Comments in-line] ------------------------------------ > Date: Sun, 19 Jul 2015 01:35:52 +0200 > From: Sawyer X > To: Perl Dancer users mailing list > Subject: Re: [dancer-users] Examining incoming POST headers. > > The DSL keywords are much more preferable since that allows us to play more > with the internals. We assure the DSL will work, but we do not assure the > internal objects will stay the same. In this specific case, I see no reason > why "request->headers" won't work forever. Using the DSL is rather nice. ;-) > > It seems like "headers" is only calling "header" again instead of literally > calling the "headers". Vincent, would you be able to raise this as a ticket > meanwhile so we could address it and you could easily track it? Sure, will do. Thanks, Vince. > > > > On Fri, Jul 17, 2015 at 9:44 AM, Lennart Hengstmengel > wrote: > > > Hi Vince, > > > > Try: > > > > my $headercontent = request->header('Your-Header-Here'); > > > > > > Kind regards, > > Lennart > > > > > > On 17-07-15 03:08, Vincent Freeman wrote: > > > >> Hi guys, > >> > >> I'm new to Dancer2 and I'm trying to access an authorization header, > >> similar to Github's 'X-Hub-Signature'. > >> > >> I consulted with > >> https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#header,it > >> says to use 'headers' to "Adds custom headers to responses" and 'header' to > >> "adds a custom header to response", but it does not say how to retrieve the > >> header information, rather than adding it. > >> > >> I'm using starman with nginx as the forward proxy. > >> > >> This is my code for testing header access: > >> > >> post '//hook' => sub { > >> my $hd = header "Content-Type";; > >> "Your Headers: [".$hd."]"; > >> }; > >> When I issue a curl, it returns empty. > >> > >> What am I doing wrong? > >> > >> Feedback welcomed and thanked in advance. > >> > >> Cheers, > >> > >> Vince. > >> _______________________________________________ > >> dancer-users mailing list > >> dancer-users at dancer.pm > >> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> > >> > > _______________________________________________ > > dancer-users mailing list > > dancer-users at dancer.pm > > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > From henk at signature.nl Sun Jul 19 05:59:08 2015 From: henk at signature.nl (Henk van Oers) Date: Sun, 19 Jul 2015 06:59:08 +0200 (CEST) Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: <20150718222845.3d969714ca39e35be6d89603@felicis.net> References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> <55A8B259.7050400@farenji.net> <20150718222845.3d969714ca39e35be6d89603@felicis.net> Message-ID: On Sat, 18 Jul 2015, Vincent Freeman wrote: > [Comments in-line] > ------------------------------------ >> Date: Sun, 19 Jul 2015 01:35:52 +0200 >> From: Sawyer X >> To: Perl Dancer users mailing list >> Subject: Re: [dancer-users] Examining incoming POST headers. >> Vincent, would you be able to raise this as a ticket >> meanwhile so we could address it and you could easily track it? > > Sure, will do. > > Thanks, > > Vince. It seems Sawyer is having trouble with his mail-client. Please close the ticket. -- Henk From kadirbeyazli at gmail.com Sun Jul 19 15:50:11 2015 From: kadirbeyazli at gmail.com (=?UTF-8?Q?Kadir_Beyazl=C4=B1?=) Date: Sun, 19 Jul 2015 17:50:11 +0300 Subject: [dancer-users] Upgrade to HTML 5 Message-ID: Hi All, I did some small changes at html definition by upgrading to html5 and committed to github. Some people may think that they are not critical changes but I think that it is important for new people starting Dancer2. For example, when I started Dancer2 approximately 2 months ago and saw HTML4 definitions instead of HTML5, I thought that it is an old framework, and developing stopped long time ago. I think we can also upgrade jquery version from 1.11.1 to 1.11.3 at views/layouts/main.tt file. I know that user can change it but I think these are important for first impression to new people. jquery has versions 1.2.* but some internet explorer versions are not supported at 1.2.* series so I am not sure if needed to use 1.2.* series. *Kadir Beyazl?* *GSM : +90 535 821 50 00* -------------- next part -------------- An HTML attachment was scrubbed... URL: From xsawyerx at gmail.com Mon Jul 20 06:43:50 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Mon, 20 Jul 2015 07:43:50 +0200 Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> <55A8B259.7050400@farenji.net> <20150718222845.3d969714ca39e35be6d89603@felicis.net> Message-ID: On Sun, Jul 19, 2015 at 6:59 AM, Henk van Oers wrote: > > On Sat, 18 Jul 2015, Vincent Freeman wrote: > > [Comments in-line] >> ------------------------------------ >> >>> Date: Sun, 19 Jul 2015 01:35:52 +0200 >>> From: Sawyer X >>> To: Perl Dancer users mailing list >>> Subject: Re: [dancer-users] Examining incoming POST headers. >>> >> > Vincent, would you be able to raise this as a ticket >>> meanwhile so we could address it and you could easily track it? >>> >> >> Sure, will do. >> >> Thanks, >> >> Vince. >> > > It seems Sawyer is having trouble with his mail-client. > That's a gracious way of saying "Sawyer hadn't noticed someone opened a ticket". :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From xsawyerx at gmail.com Mon Jul 20 06:46:54 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Mon, 20 Jul 2015 07:46:54 +0200 Subject: [dancer-users] Examining incoming POST headers. In-Reply-To: References: <20150716210820.a610ee47f8acac572293edaa@felicis.net> <55A8B259.7050400@farenji.net> <20150718222845.3d969714ca39e35be6d89603@felicis.net> Message-ID: On Mon, Jul 20, 2015 at 7:43 AM, Sawyer X wrote: > On Sun, Jul 19, 2015 at 6:59 AM, Henk van Oers wrote: > >> >> On Sat, 18 Jul 2015, Vincent Freeman wrote: >> >> [Comments in-line] >>> ------------------------------------ >>> >>>> Date: Sun, 19 Jul 2015 01:35:52 +0200 >>>> From: Sawyer X >>>> To: Perl Dancer users mailing list >>>> Subject: Re: [dancer-users] Examining incoming POST headers. >>>> >>> >> Vincent, would you be able to raise this as a ticket >>>> meanwhile so we could address it and you could easily track it? >>>> >>> >>> Sure, will do. >>> >>> Thanks, >>> >>> Vince. >>> >> >> It seems Sawyer is having trouble with his mail-client. >> > > That's a gracious way of saying "Sawyer hadn't noticed someone opened a > ticket". :) > And in case anyone is not sure what Henk is referring to, I'll add a few words: https://github.com/PerlDancer/Dancer2/issues/956 Henk has commented, rightfully, that the "headers" keyword actually refers to setting response headers, not getting the request headers. That's the confusion (even for me, since I don't even remember ever using the "headers" keyword) and that is why this shouldn't be an issue with the keyword. Thanks, Henk! :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From ZahirLalani at oliver.agency Sun Jul 19 10:32:08 2015 From: ZahirLalani at oliver.agency (Zahir Lalani) Date: Sun, 19 Jul 2015 09:32:08 +0000 Subject: [dancer-users] JSON Serialiser In-Reply-To: References: Message-ID: --From: dancer-users [mailto:dancer-users-bounces at dancer.pm] On Behalf Of Sawyer X --Sent: 19 July 2015 00:31 --To: Perl Dancer users mailing list --Subject: Re: [dancer-users] JSON Serialiser --I don't understand this email. T abundance of HTML in your message is quite disruptive. ------ My apologies for the confusion. Let me try again?.. I had code which was working just fine two months ago. It relied on the automatic JSON deserialise + blessed objects. I was able to "return" a Moo object as a response to a REST request and the output would correctly show the json. So the basic format for this is: get '/xxxx' => sub { return AnObject->new; }; AnObject has TO_JSON implemented. I came back to this project after 2 months and found that it no longer worked - I would get an error of the form " Unrecognized response type from route". I found a thread from April 15th which showed the same issue and a solution. (this is what I tried to include!). The solution was to wrap the response object in a hash as below: get '/xxxx' => sub { return { result => AnObject->new }; }; My question is: which should be the correct way. My previous way worked and then something must have changed. Was the change deliberate? I have no issue with the solution above, I just want to understand whether this is the expected behaviour now. Z From sakshee3 at gmail.com Tue Jul 21 09:33:52 2015 From: sakshee3 at gmail.com (Sakshee Vijayvargia) Date: Tue, 21 Jul 2015 14:03:52 +0530 Subject: [dancer-users] Fwd: Contributor's Guide Content In-Reply-To: References: Message-ID: Hello, I propose to you all the content of Contributor's guide on which I am working currently. I request you all to review it once and give your valuable comments. > 1. Introduction to dancer > 2. Migration frm dancer to dancer2 > 3. Features of dancer2 > > 4. Dancer2 modules explained on metacpan > > 5. How dancer2 works > > 6. How routing works in dancer 2 > > 7. Explaning all this: > Testing PSGI web applications: http://advent.perldancer.org/2014/12 > > How we test Dancer internally: http://advent.perldancer.org/2014/13 > > AutoPages feature: http://advent.perldancer.org/2014/17 > > Example of dynamic routes in Dancer: http://advent.perldancer.org/2014/23 > > Serializers feature: http://advent.perldancer.org/2014/11 > Middlewares in Dancer: http://advent.perldancer.org/2014/20 > Thanks Sakshee -------------- next part -------------- An HTML attachment was scrubbed... URL: From henk at signature.nl Tue Jul 21 09:47:08 2015 From: henk at signature.nl (Henk van Oers) Date: Tue, 21 Jul 2015 10:47:08 +0200 (CEST) Subject: [dancer-users] Fwd: Contributor's Guide Content In-Reply-To: References: Message-ID: On Tue, 21 Jul 2015, Sakshee Vijayvargia wrote: > Hello,? > > I propose to you all the content of Contributor's guide on which I am working currently.? > I request you all to review it once and give your valuable comments. ?? OK. Do you have a link to that document? -- Henk From aireland at lbl.gov Tue Jul 21 19:07:24 2015 From: aireland at lbl.gov (Amelia Ireland) Date: Tue, 21 Jul 2015 11:07:24 -0700 Subject: [dancer-users] Multiple config files for Dancer2 app Message-ID: Hello all, Is there a recommended method for using multiple configuration files for a Dancer2 application in addition to the config.xxx and development.xxx/production.xxx files? My app uses a couple of databases with passwords that are changed on a regular basis, and I'd like to be able to drop DB config files into the environments folder and have them automatically included rather than having to edit config files by hand or regenerate them by script. If there's something that already exists that I can use, that would be great! Thanks! Amelia. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aireland at lbl.gov Wed Jul 22 23:41:57 2015 From: aireland at lbl.gov (Amelia Ireland) Date: Wed, 22 Jul 2015 15:41:57 -0700 Subject: [dancer-users] Multiple config files for Dancer2 app Message-ID: To answer my own question, the easiest thing is probably going to be for me to call ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 21 Jul 2015 11:07:24 -0700 > From: Amelia Ireland > To: dancer-users at dancer.pm > Subject: [dancer-users] Multiple config files for Dancer2 app > Message-ID: > < > CAEWSiHi-JDpm-aQz1s-Tk4ZT5xuZcqDUhJ0hP19U9a9fey+f2w at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Hello all, > > Is there a recommended method for using multiple configuration files for a > Dancer2 application in addition to the config.xxx and > development.xxx/production.xxx files? My app uses a couple of databases > with passwords that are changed on a regular basis, and I'd like to be able > to drop DB config files into the environments folder and have them > automatically included rather than having to edit config files by hand or > regenerate them by script. If there's something that already exists that I > can use, that would be great! > > Thanks! > Amelia. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150721/d3300e26/attachment-0001.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > > ------------------------------ > > End of dancer-users Digest, Vol 65, Issue 10 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aireland at lbl.gov Wed Jul 22 23:48:00 2015 From: aireland at lbl.gov (Amelia Ireland) Date: Wed, 22 Jul 2015 15:48:00 -0700 Subject: [dancer-users] Multiple config files for Dancer2 app In-Reply-To: References: Message-ID: (Apologies for the accidental post) To answer my own question, the easiest thing is to use app->load_config_file(...) and merge the settings into the app config. On 22 July 2015 at 15:41, Amelia Ireland wrote: > > To answer my own question, the easiest thing is probably going to be for me to call > > ---------------------------------------------------------------------- >> >> >> Message: 1 >> Date: Tue, 21 Jul 2015 11:07:24 -0700 >> From: Amelia Ireland >> To: dancer-users at dancer.pm >> Subject: [dancer-users] Multiple config files for Dancer2 app >> Message-ID: >> < CAEWSiHi-JDpm-aQz1s-Tk4ZT5xuZcqDUhJ0hP19U9a9fey+f2w at mail.gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> >> Hello all, >> >> Is there a recommended method for using multiple configuration files for a >> Dancer2 application in addition to the config.xxx and >> development.xxx/production.xxx files? My app uses a couple of databases >> with passwords that are changed on a regular basis, and I'd like to be able >> to drop DB config files into the environments folder and have them >> automatically included rather than having to edit config files by hand or >> regenerate them by script. If there's something that already exists that I >> can use, that would be great! >> >> Thanks! >> Amelia. >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> URL: < http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150721/d3300e26/attachment-0001.html > >> >> ------------------------------ >> >> Subject: Digest Footer >> >> _______________________________________________ >> dancer-users mailing list >> dancer-users at dancer.pm >> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users >> >> >> ------------------------------ >> >> End of dancer-users Digest, Vol 65, Issue 10 >> ******************************************** > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From xsawyerx at gmail.com Thu Jul 23 18:31:45 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Thu, 23 Jul 2015 19:31:45 +0200 Subject: [dancer-users] Multiple config files for Dancer2 app In-Reply-To: References: Message-ID: I suggest not using Dancer2 for the config loading here. The config loading for Dancer2 really should be for the framework. Even though you can add configurations for the app, it seems like a very custom and advanced situation. What I recommend is having a setup() method in your app that loads configuration files for the database handles. Then you call that setup and *then* call ->to_app. Do you understand what I mean? On Thu, Jul 23, 2015 at 12:48 AM, Amelia Ireland wrote: > (Apologies for the accidental post) > > To answer my own question, the easiest thing is to use > app->load_config_file(...) and merge the settings into the app config. > > > On 22 July 2015 at 15:41, Amelia Ireland wrote: > > > > To answer my own question, the easiest thing is probably going to be for > me to call > > > > ---------------------------------------------------------------------- > >> > >> > >> Message: 1 > >> Date: Tue, 21 Jul 2015 11:07:24 -0700 > >> From: Amelia Ireland > >> To: dancer-users at dancer.pm > >> Subject: [dancer-users] Multiple config files for Dancer2 app > >> Message-ID: > >> < > CAEWSiHi-JDpm-aQz1s-Tk4ZT5xuZcqDUhJ0hP19U9a9fey+f2w at mail.gmail.com> > >> Content-Type: text/plain; charset="utf-8" > >> > >> > >> Hello all, > >> > >> Is there a recommended method for using multiple configuration files > for a > >> Dancer2 application in addition to the config.xxx and > >> development.xxx/production.xxx files? My app uses a couple of databases > >> with passwords that are changed on a regular basis, and I'd like to be > able > >> to drop DB config files into the environments folder and have them > >> automatically included rather than having to edit config files by hand > or > >> regenerate them by script. If there's something that already exists > that I > >> can use, that would be great! > >> > >> Thanks! > >> Amelia. > >> -------------- next part -------------- > >> An HTML attachment was scrubbed... > >> URL: < > http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150721/d3300e26/attachment-0001.html > > > >> > >> ------------------------------ > >> > >> Subject: Digest Footer > >> > >> _______________________________________________ > >> dancer-users mailing list > >> dancer-users at dancer.pm > >> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > >> > >> > >> ------------------------------ > >> > >> End of dancer-users Digest, Vol 65, Issue 10 > >> ******************************************** > > > > > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From xsawyerx at gmail.com Thu Jul 23 18:33:59 2015 From: xsawyerx at gmail.com (Sawyer X) Date: Thu, 23 Jul 2015 19:33:59 +0200 Subject: [dancer-users] JSON Serialiser In-Reply-To: References: Message-ID: Hmm... I'm not sure why you're getting this problem. Usually the problem people have is confusing routes that return HTML to ones that return JSON and then expecting it to handle both in the same App (which we removed for several reasons - as explained in blog posts, the advent calendar, the mailing list, Github, and the changelog). However, I'm not sure why *this* wouldn't work. Can you reduce this to a test case? I would be happy to understand this better. On Sun, Jul 19, 2015 at 11:32 AM, Zahir Lalani wrote: > --From: dancer-users [mailto:dancer-users-bounces at dancer.pm] On Behalf Of > Sawyer X > --Sent: 19 July 2015 00:31 > --To: Perl Dancer users mailing list > --Subject: Re: [dancer-users] JSON Serialiser > > --I don't understand this email. T abundance of HTML in your message is > quite disruptive. > ------ > > My apologies for the confusion. Let me try again?.. > > I had code which was working just fine two months ago. It relied on the > automatic JSON deserialise + blessed objects. I was able to "return" a Moo > object as a response to a REST request and the output would correctly show > the json. So the basic format for this is: > > get '/xxxx' => sub { > return AnObject->new; > }; > > AnObject has TO_JSON implemented. > > I came back to this project after 2 months and found that it no longer > worked - I would get an error of the form " Unrecognized response type from > route". I found a thread from April 15th which showed the same issue and a > solution. (this is what I tried to include!). The solution was to wrap the > response object in a hash as below: > > get '/xxxx' => sub { > return { result => AnObject->new }; > }; > > My question is: which should be the correct way. My previous way worked > and then something must have changed. Was the change deliberate? I have no > issue with the solution above, I just want to understand whether this is > the expected behaviour now. > > Z > > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ZahirLalani at oliver.agency Thu Jul 23 18:47:05 2015 From: ZahirLalani at oliver.agency (Zahir Lalani) Date: Thu, 23 Jul 2015 17:47:05 +0000 Subject: [dancer-users] JSON Serialiser In-Reply-To: References: , Message-ID: Yes will do. z Sent from my HTC ----- Reply message ----- From: "Sawyer X" To: "Perl Dancer users mailing list" Subject: [dancer-users] JSON Serialiser Date: Thu, Jul 23, 2015 22:34 Hmm... I'm not sure why you're getting this problem. Usually the problem people have is confusing routes that return HTML to ones that return JSON and then expecting it to handle both in the same App (which we removed for several reasons - as explained in blog posts, the advent calendar, the mailing list, Github, and the changelog). However, I'm not sure why *this* wouldn't work. Can you reduce this to a test case? I would be happy to understand this better. On Sun, Jul 19, 2015 at 11:32 AM, Zahir Lalani > wrote: --From: dancer-users [mailto:dancer-users-bounces at dancer.pm] On Behalf Of Sawyer X --Sent: 19 July 2015 00:31 --To: Perl Dancer users mailing list --Subject: Re: [dancer-users] JSON Serialiser --I don't understand this email. T abundance of HTML in your message is quite disruptive. ------ My apologies for the confusion. Let me try again..... I had code which was working just fine two months ago. It relied on the automatic JSON deserialise + blessed objects. I was able to "return" a Moo object as a response to a REST request and the output would correctly show the json. So the basic format for this is: get '/xxxx' => sub { return AnObject->new; }; AnObject has TO_JSON implemented. I came back to this project after 2 months and found that it no longer worked - I would get an error of the form " Unrecognized response type from route". I found a thread from April 15th which showed the same issue and a solution. (this is what I tried to include!). The solution was to wrap the response object in a hash as below: get '/xxxx' => sub { return { result => AnObject->new }; }; My question is: which should be the correct way. My previous way worked and then something must have changed. Was the change deliberate? I have no issue with the solution above, I just want to understand whether this is the expected behaviour now. Z _______________________________________________ dancer-users mailing list dancer-users at dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From gatorreina at gmail.com Fri Jul 31 15:20:33 2015 From: gatorreina at gmail.com (Richard Reina) Date: Fri, 31 Jul 2015 09:20:33 -0500 Subject: [dancer-users] Helping getting simple CRUD to dance Message-ID: When I try to execute this app: #!/usr/bin/perl use Dancer; use Dancer::Plugin::SimpleCRUD; # Simple example: simple_crud( record_title => 'Player', prefix => '/player', db_table => 'jugador', editable => 1, ); dance; I get as my result in the browser: Error 404 Unable to process your query -- This is my config.yml file: plugins: Database: driver: 'mysql' database: 'my_main_DB' host: 'localhost' port: 3306 username: 'richard' password: 'mypass' #connection_check_threshold: 10 dbi_params: RaiseError: 1 AutoCommit: 1 on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ] log_queries: 1 Any help is greatly appreciated. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at stoffel.org Fri Jul 31 19:05:28 2015 From: john at stoffel.org (John Stoffel) Date: Fri, 31 Jul 2015 14:05:28 -0400 Subject: [dancer-users] Helping getting simple CRUD to dance In-Reply-To: References: Message-ID: <21947.47336.5738.383495@quad.stoffel.home> What URL are you going to? I assume http://localhost:3000 ? But more details and logs would help. John From gatorreina at gmail.com Fri Jul 31 21:16:07 2015 From: gatorreina at gmail.com (Richard Reina) Date: Fri, 31 Jul 2015 15:16:07 -0500 Subject: [dancer-users] Helping getting simple CRUD to dance In-Reply-To: <21947.47336.5738.383495@quad.stoffel.home> References: <21947.47336.5738.383495@quad.stoffel.home> Message-ID: John, Thanks for the reply. That was exactly the problem -- I wasn't using the dull URL. Thanks 2015-07-31 13:05 GMT-05:00 John Stoffel : > > What URL are you going to? I assume http://localhost:3000 ? But more > details and logs would help. > > John > _______________________________________________ > dancer-users mailing list > dancer-users at dancer.pm > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: