Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

How to forward to a specific path

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


julien at sobrier

Jan 1, 2010, 2:26 PM

Post #1 of 8 (1625 views)
Permalink
How to forward to a specific path

Hello,
I'm try to do a forward to a path rather than a controller. For example, if
I get the url /foo/my/path, I want to redirect it to /my/path which belongs
to a different controller. In the controllfer Foo, I tried something like
this:

sub foo :Path :Args {
my ($self, $c) = @_

$c->forward("/" . join("/", @{$c->req->args}); # $c->forward("/my/path");
}


I cannot fin the righrt command to forward to any path.

Thank you
Julien


tamas at eisenberger

Jan 1, 2010, 3:39 PM

Post #2 of 8 (1565 views)
Permalink
Re: How to forward to a specific path [In reply to]

Hy!

I think your problem is that there is a difference between how an url
dispatched to an action, and how forward finds the action to forward to...

so for example, if you have a controller (YourApp::Controller::Foo) with
an index method you can access it with the url path /foo, but you should
use /foo/index in forward... so the 'private' path to the action is
different from the 'public' path in many times!

On 01/01/2010 11:26 PM, Julien Sobrier wrote:
> Hello,
> I'm try to do a forward to a path rather than a controller. For
> example, if I get the url /foo/my/path, I want to redirect it to
> /my/path which belongs to a different controller. In the controllfer
> Foo, I tried something like this:
>
> sub foo :Path :Args {
> my ($self, $c) = @_
>
> $c->forward("/" . join("/", @{$c->req->args}); #
> $c->forward("/my/path");
> }
>
>
> I cannot fin the righrt command to forward to any path.
>
> Thank you
> Julien
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
Attachments: smime.p7s (4.70 KB)


julien at sobrier

Jan 1, 2010, 4:31 PM

Post #3 of 8 (1556 views)
Permalink
Re: How to forward to a specific path [In reply to]

Right,
but this mapping is stored somewhere since it is displayed by Catalyst in
debug mode:

.-------------------------------------+--------------------------------------.
| Path | Private |
+-------------------------------------+--------------------------------------+
| / | /index
|
| / | /default
|
| /admin | /admin/admin |


2010/1/1 Eisenberger Tamás <tamas [at] eisenberger>

> Hy!
>
> I think your problem is that there is a difference between how an url
> dispatched to an action, and how forward finds the action to forward to...
>
> so for example, if you have a controller (YourApp::Controller::Foo) with an
> index method you can access it with the url path /foo, but you should use
> /foo/index in forward... so the 'private' path to the action is different
> from the 'public' path in many times!
>
>
> On 01/01/2010 11:26 PM, Julien Sobrier wrote:
>
> Hello,
> I'm try to do a forward to a path rather than a controller. For example, if
> I get the url /foo/my/path, I want to redirect it to /my/path which belongs
> to a different controller. In the controllfer Foo, I tried something like
> this:
>
> sub foo :Path :Args {
> my ($self, $c) = @_
>
> $c->forward("/" . join("/", @{$c->req->args}); #
> $c->forward("/my/path");
> }
>
>
> I cannot fin the righrt command to forward to any path.
>
> Thank you
> Julien
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>
>


larryl at emailplus

Jan 1, 2010, 8:19 PM

Post #4 of 8 (1550 views)
Permalink
Re: How to forward to a specific path [In reply to]

Hi Julien -

On Fri, 01 Jan 2010 14:26 -0800, "Julien Sobrier" <julien [at] sobrier>
wrote:

> Hello, I'm try to do a forward to a path rather than a controller. For
> example, if I get the url /foo/my/path, I want to redirect it to
> /my/path which belongs to a different controller.

In general you should be able to forward() to a path, not sure what is
going on in your case without seeing the error message. But forwarding
to a path can get confused if that path is handled by a default action,
if that is the case then this might help:

http://dev.catalyst.perl.org/wiki/wikicookbook/safedispatchusingpath


HTH,
Larry

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


julien at sobrier

Jan 1, 2010, 11:04 PM

Post #5 of 8 (1550 views)
Permalink
Re: How to forward to a specific path [In reply to]

Exactly what I needed, thanks a lot.

On Fri, Jan 1, 2010 at 8:19 PM, Larry Leszczynski <larryl [at] emailplus>wrote:

> Hi Julien -
>
> On Fri, 01 Jan 2010 14:26 -0800, "Julien Sobrier" <julien [at] sobrier>
> wrote:
>
> > Hello, I'm try to do a forward to a path rather than a controller. For
> > example, if I get the url /foo/my/path, I want to redirect it to
> > /my/path which belongs to a different controller.
>
> In general you should be able to forward() to a path, not sure what is
> going on in your case without seeing the error message. But forwarding
> to a path can get confused if that path is handled by a default action,
> if that is the case then this might help:
>
> http://dev.catalyst.perl.org/wiki/wikicookbook/safedispatchusingpath
>
>
> HTH,
> Larry
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>


pagaltzis at gmx

Jan 2, 2010, 4:09 AM

Post #6 of 8 (1544 views)
Permalink
Re: How to forward to a specific path [In reply to]

Hi Julien,

* Julien Sobrier <julien [at] sobrier> [2010-01-01 23:30]:
> I'm try to do a forward to a path rather than a controller. For
> example, if I get the url /foo/my/path, I want to redirect it
> to /my/path which belongs to a different controller.

this sounds like there may be a way to achieve the goal you are
trying to achieve. What is your goal here?

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


julien at sobrier

Jan 25, 2010, 9:30 PM

Post #7 of 8 (1254 views)
Permalink
Re: Re: How to forward to a specific path [In reply to]

Thanks.

I have pages in /page/<number>/<title>

I created a couple of categories: /ca1, /cat2, etc. Each of them map to a
/page/<number>/<title>

/page/1/some-title
/cat1/page/1/some-title
/cat2/page/1/some-title

For cat1 and cat2, I wanted to set some variables. So I intercept the page
in /cat1 and send it back to /page/1/some-title

/cat1, /cat2 and /page reside in different controller.

I'm just starting with Catalyst, so there might be a better way to do it.


Julien


On Sat, Jan 2, 2010 at 4:09 AM, Aristotle Pagaltzis <pagaltzis [at] gmx>wrote:

> Hi Julien,
>
> * Julien Sobrier <julien [at] sobrier> [2010-01-01 23:30]:
> > I'm try to do a forward to a path rather than a controller. For
> > example, if I get the url /foo/my/path, I want to redirect it
> > to /my/path which belongs to a different controller.
>
> this sounds like there may be a way to achieve the goal you are
> trying to achieve. What is your goal here?
>
> Regards,
> --
> Aristotle Pagaltzis // <http://plasmasturm.org/>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>


pagaltzis at gmx

Jan 31, 2010, 4:50 AM

Post #8 of 8 (1184 views)
Permalink
Re: How to forward to a specific path [In reply to]

* Julien Sobrier <julien [at] sobrier> [2010-01-26 06:30]:
> I have pages in /page/<number>/<title>
>
> I created a couple of categories: /ca1, /cat2, etc. Each of
> them map to a /page/<number>/<title>
>
> /page/1/some-title
> /cat1/page/1/some-title
> /cat2/page/1/some-title
>
> For cat1 and cat2, I wanted to set some variables. So
> I intercept the page in /cat1 and send it back to
> /page/1/some-title
>
> /cat1, /cat2 and /page reside in different controller.

OK, but that doesn’t explain why you need to forward to a URI
rather than an action. Why is that?

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.