return forward "/ticket/$tid/set?assign=1"; Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167. Am I doing something wrong? ps:I have `any '/ticket/:tid/set' => sub {...};` -- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
On 15/04/2011 02:19, Nick Knutov wrote:
return forward "/ticket/$tid/set?assign=1";
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167.
Am I doing something wrong?
ps:I have `any '/ticket/:tid/set' => sub {...};`
Hello any ['get','post'] '/ticket... You need to specify the set from which any will act. Cheers
But why? As I understood from documentation, 'any' includes all of them, including 'get' and 'post'. And it is working for direct queries. Why should I specify them additionally? On 15.04.2011 14:05, ambs wrote:
On 15/04/2011 02:19, Nick Knutov wrote:
return forward "/ticket/$tid/set?assign=1";
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167.
Am I doing something wrong?
ps:I have `any '/ticket/:tid/set' => sub {...};`
Hello
any ['get','post'] '/ticket...
You need to specify the set from which any will act.
Cheers
-- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
On 15/04/2011 12:37, Nick Knutov wrote:
But why? As I understood from documentation, 'any' includes all of them, including 'get' and 'post'. And it is working for direct queries. Why should I specify them additionally?
As far as I know (but I might be wrong, so, anyone else, correct me) any doesn't include all. It lets a route chose from a list. If you want them all, really, add: any ['get','post','put',...], '...' Cheers Alberto
On 15.04.2011 14:05, ambs wrote:
On 15/04/2011 02:19, Nick Knutov wrote:
return forward "/ticket/$tid/set?assign=1";
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167.
Am I doing something wrong?
ps:I have `any '/ticket/:tid/set' => sub {...};`
Hello
any ['get','post'] '/ticket...
You need to specify the set from which any will act.
Cheers
According to Cookbook 'any' includes all methods http://search.cpan.org/dist/Dancer/lib/Dancer/Cookbook.pod#Handling_multiple... in Route/Registry.pm default value of @methods is also defined as qw(get post put delete options); [mephist@vm Dancer]$ grep -A15 'any_add' Route/Registry.pm sub any_add { my ($self, $pattern, @rest) = @_; my @methods = qw(get post put delete options); if (ref($pattern) eq 'ARRAY') { @methods = @$pattern; $pattern = shift @rest; } croak "Syntax error, methods should be provided as an ARRAY ref" if grep {$_ eq $pattern} @methods; $self->universal_add($_, $pattern, @rest) for @methods; return scalar(@methods); } 15.04.2011 16:44, ambs пишет:
On 15/04/2011 12:37, Nick Knutov wrote:
But why? As I understood from documentation, 'any' includes all of them, including 'get' and 'post'. And it is working for direct queries. Why should I specify them additionally?
As far as I know (but I might be wrong, so, anyone else, correct me) any doesn't include all. It lets a route chose from a list.
If you want them all, really, add:
any ['get','post','put',...], '...'
Cheers Alberto
On 15.04.2011 14:05, ambs wrote:
On 15/04/2011 02:19, Nick Knutov wrote:
return forward "/ticket/$tid/set?assign=1";
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167.
Am I doing something wrong?
ps:I have `any '/ticket/:tid/set' => sub {...};`
Hello
any ['get','post'] '/ticket...
You need to specify the set from which any will act.
Cheers
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hello, Maxim It seems it is my error. I didn't know that. Getting back to the original bug, by Nick.
On 15/04/2011 02:19, Nick Knutov wrote:
return forward "/ticket/$tid/set?assign=1";
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167.
Can you prepare a small case where this happens so it gets easier to debug? Meanwhile, I'll try to find out if using that line I can understand where a non-array value can be constructed. Thanks Alberto
$ dancer -v Dancer 1.3030 dancer -a test2 $ cat ./lib/test2.pm ============ package test2; use Dancer ':syntax'; use Data::Dumper; any '/ticket/:tid/set' => sub { my $tid = params->{tid}; return Dumper(params->{assign}); }; get '/ticket/:tid/assign' => sub { my $tid = params->{tid}; return forward "/ticket/$tid/set?assign=1"; }; true; ============ http://localhost:3001/ticket/123/set?assign=123 - is ok http://localhost:3001/ticket/123/set - also ok http://localhost:3001/ticket/123/assign - not ok plackup -E development -p 3001 -r -R ./lib -a ./bin/app.pl if it does matter. On 15.04.2011 18:59, ambs wrote:
Hello, Maxim
It seems it is my error. I didn't know that. Getting back to the original bug, by Nick.
On 15/04/2011 02:19, Nick Knutov wrote:
return forward "/ticket/$tid/set?assign=1";
Not an ARRAY reference at /usr/local/share/perl/5.10.1/Dancer/Route.pm line 167.
Can you prepare a small case where this happens so it gets easier to debug?
Meanwhile, I'll try to find out if using that line I can understand where a non-array value can be constructed.
Thanks Alberto
-- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
On 15/04/2011 16:22, Nick Knutov wrote:
any '/ticket/:tid/set' => sub { my $tid = params->{tid}; return Dumper(params->{assign}); };
get '/ticket/:tid/assign' => sub { my $tid = params->{tid}; return forward "/ticket/$tid/set?assign=1"; };
Great. Being able to reproduce. Will be back when I have news :)
Hi On 15/04/2011 16:22, Nick Knutov wrote:
$ dancer -v Dancer 1.3030
dancer -a test2
$ cat ./lib/test2.pm ============ package test2; use Dancer ':syntax';
use Data::Dumper;
any '/ticket/:tid/set' => sub { my $tid = params->{tid}; return Dumper(params->{assign}); };
get '/ticket/:tid/assign' => sub { my $tid = params->{tid}; return forward "/ticket/$tid/set?assign=1"; };
true;
Dancer does not support in its current form that you forward with GET parameters (as far as I can tell). It can't find the route. You are getting the error on the marshalling code because of other bug that I fixed, and I'm preparing in a Pull Request. After updating to that code you will get a 404 page. Not very useful as well. I'll create an issue regarding passing parameters in a forward, so someone (probably me) can fix it in the future. For now, I would suggest you to use path variables to get your desired behavior. Cheers ambs
get '/ticket/:tid/assign' => sub { my $tid = params->{tid}; return forward "/ticket/$tid/set?assign=1"; };
or yet... try this (didn't have the time to test for myself) get '/ticket/:tid/assign' => sub { my $tid = params->{tid}; params->{assign} = 1; return forward "/ticket/$tid/set"; }; Cheers
There is another thing that bothers me - according to documentation if I use it to, for example, change DB or some environment before "forward", usually I should want to change it back after "forward" will processed. And usually I may need "sub before" will be processed before every internal request (if I am using CGI::WebIn or something like that). All of this is impossible now and maybe there is reason to redesign the whole forward mechanism. On 15.04.2011 21:56, ambs wrote:
Not very useful as well.
I'll create an issue regarding passing parameters in a forward, so someone (probably me) can fix it in the future.
-- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
participants (3)
-
ambs -
Maxim Nikolenko -
Nick Knutov