FAQ
Hi
I thought I had a grip on this, but obviously I am missing some nuance.

I wish to match the following URLs to controllers.

/
/*
/*/*
/pod
/pod/*

All the above work correctly, with the exception of '/pod/*' which dispatches
as if it were '/*/*'.

My understanding is that the most specific should be chosen first, so '/pod/*'
should be chosen in preference to '/*/*'?

Currently running Catalyst 5.80030

My Root.pm is as follows.

---------
package myapp::Controller::Root;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller' }

__PACKAGE__->config->{namespace} = '';

sub index : Path('/') : Args(0) {
my ( $self, $c ) = @_;
$c->response->body( 'index' );
}
sub api : Chained('/') PathPart('') CaptureArgs(1) {
my ($self, $c, $item) = @_;
$c->stash->{item} = $item;
}
sub path_without_arg :Chained('api') :PathPart('') :Args(0) {
my ($self, $c) = @_;
$c->response->body( "path_without_arg - item ".$c->stash->{item} );
}
sub path_with_arg :Chained('api') :PathPart('') :Args(1) {
my ($self, $c, $arg) = @_;
$c->response->body( "path_with_arg - item ".$c->stash->{item}." arg $arg" );
}
__PACKAGE__->meta->make_immutable;
1;

---------
My Pod.pm is as follows
---------

package myapp::Controller::Pod;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller' }

sub pod_index : Path('') : Args(0) {
my ($self, $c) = @_;
$c->response->body( "pod_index" );
}
sub pod : Path('/pod') : Args(1) {
my ($self, $c, $file) = @_;
$c->response->body( "pod - file = $file" );
}
__PACKAGE__->meta->make_immutable;
1;
---------

Regards
Ian Docherty




This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm

Search Discussions

  • Denny at May 12, 2011 at 9:42 am

    On Thu, 2011-05-12 at 09:29 +0000, Ian.Docherty@nomura.com wrote:
    All the above work correctly, with the exception of '/pod/*' which dispatches
    as if it were '/*/*'.
    ...
    sub pod : Path('/pod') : Args(1) {
    Does removing the slash before 'pod' help?

    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: not available
    Type: application/pgp-signature
    Size: 490 bytes
    Desc: This is a digitally signed message part
    Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110512/d3d4a4f8/attachment.pgp
  • Ian Docherty at May 12, 2011 at 9:48 am
    No, in my 'try things at random' approach I already tried that
    and it had no effect.


    -----Original Message-----
    From: Denny
    Sent: 12 May 2011 10:42
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Dispatching not working as expected.
    On Thu, 2011-05-12 at 09:29 +0000, Ian.Docherty@nomura.com wrote:
    All the above work correctly, with the exception of '/pod/*' which
    dispatches as if it were '/*/*'.
    ...
    sub pod : Path('/pod') : Args(1) {
    Does removing the slash before 'pod' help?




    This e-mail (including any attachments) is confidential, may contain
    proprietary or privileged information and is intended for the named
    recipient(s) only. Unintended recipients are prohibited from taking action
    on the basis of information in this e-mail and must delete all copies.
    Nomura will not accept responsibility or liability for the accuracy or
    completeness of, or the presence of any virus or disabling code in, this
    e-mail. If verification is sought please request a hard copy. Any reference
    to the terms of executed transactions should be treated as preliminary only
    and subject to formal written confirmation by Nomura. Nomura reserves the
    right to monitor e-mail communications through its networks (in accordance
    with applicable laws). No confidentiality or privilege is waived or lost by
    Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
    a reference to any entity in the Nomura Holdings, Inc. group. Please read
    our Electronic Communications Legal Notice which forms part of this e-mail:
    http://www.Nomura.com/email_disclaimer.htm
  • Tomas Doran at May 12, 2011 at 12:01 pm

    On 12 May 2011, at 10:29, <Ian.Docherty@nomura.com> wrote:
    All the above work correctly, with the exception of '/pod/*' which
    dispatches
    as if it were '/*/*'.

    My understanding is that the most specific should be chosen first,
    so '/pod/*'
    should be chosen in preference to '/*/*'?
    This will happen if you have multiple possible chained matches.

    However you have one set of chained matches, and one set of Path
    matches - so the result is pretty undefined.

    I'd recommend you change your pod controller over to also use Chained,
    then I think you'll find things more likely to work as you expect.

    Cheers
    t0m
  • Ian Docherty at May 12, 2011 at 12:38 pm
    -----Original Message-----
    From: Tomas Doran
    Sent: 12 May 2011 13:02
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Dispatching not working as expected.

    On 12 May 2011, at 10:29, <Ian.Docherty@nomura.com> wrote:
    All the above work correctly, with the exception of '/pod/*' which
    dispatches
    as if it were '/*/*'.

    My understanding is that the most specific should be chosen first,
    so '/pod/*'
    should be chosen in preference to '/*/*'?
    This will happen if you have multiple possible chained matches.

    However you have one set of chained matches, and one set of Path
    matches - so the result is pretty undefined.

    I'd recommend you change your pod controller over to also use Chained,
    then I think you'll find things more likely to work as you expect.

    Cheers
    t0m

    t0m
    Thanks for that suggestion, and I see where you are coming from, I changed
    my pod controller as follows, but it has the same problem.

    ----------

    sub pod : Chained('') PathPart('') CaptureArgs(0) {
    my ($self, $c) = @_;
    }

    sub pod_without_arg :Chained('pod') :PathPart('') :Args(0) {
    my ($self, $c) = @_;
    $c->response->body( "pod_without_arg" );
    }

    sub pod_with_arg :Chained('pod') :PathPart('') :Args(1) {
    my ($self, $c, $file) = @_;
    $c->response->body( "pod_with_arg - file = $file" );
    }




    This e-mail (including any attachments) is confidential, may contain
    proprietary or privileged information and is intended for the named
    recipient(s) only. Unintended recipients are prohibited from taking action
    on the basis of information in this e-mail and must delete all copies.
    Nomura will not accept responsibility or liability for the accuracy or
    completeness of, or the presence of any virus or disabling code in, this
    e-mail. If verification is sought please request a hard copy. Any reference
    to the terms of executed transactions should be treated as preliminary only
    and subject to formal written confirmation by Nomura. Nomura reserves the
    right to monitor e-mail communications through its networks (in accordance
    with applicable laws). No confidentiality or privilege is waived or lost by
    Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
    a reference to any entity in the Nomura Holdings, Inc. group. Please read
    our Electronic Communications Legal Notice which forms part of this e-mail:
    http://www.Nomura.com/email_disclaimer.htm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMay 12, '11 at 9:29a
activeMay 12, '11 at 12:38p
posts5
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase