FAQ
Hi, all.

Catalyst::Manual::Intro.pod declare "Unrestrained URL-to-Action
Dispatching" in Catalyst.
Well, but i think all of dispatching types (Path, Regex, Global,
Local) badly link up URL and his handler.
For example, i have some forum Controller, begining with url
"/forum/". Later, i want move it to "/communication/" or
"/communication/forum/". What i need to do it?
Change source - rename perl modules or attributes of subs? I belief
that wrong end.
Question. It is possible in Catalist link Controller to URL by some
kind of configuration change (not Controller source)?
I'am will be glad mistaken, but while i did'nt found this in
documentation.

Thanks.


--
Maxim Nechaev

Search Discussions

  • Sebastian Riedel at Nov 14, 2005 at 6:39 am

    Am 14.11.2005 um 06:06 schrieb Maxim Nechaev:

    Hi, all.

    Catalyst::Manual::Intro.pod declare "Unrestrained URL-to-Action
    Dispatching" in Catalyst.
    Well, but i think all of dispatching types (Path, Regex, Global,
    Local) badly link up URL and his handler.
    For example, i have some forum Controller, begining with url
    "/forum/". Later, i want move it to "/communication/" or
    "/communication/forum/". What i need to do it?
    Change source - rename perl modules or attributes of subs? I belief
    that wrong end.
    Question. It is possible in Catalist link Controller to URL by some
    kind of configuration change (not Controller source)?
    I'am will be glad mistaken, but while i did'nt found this in
    documentation.
    Short answer: Use Local actions and mod_rewrite or a custom rewrite
    plugin.

    Not so short answer: Your "forum" controller looks like it wants to
    be a application, which could be deployed as a mod_perl handler or
    FCGI with whatever prefix you want. There is no need to stuff all
    functionality in a single Cat app just because it's possible.

    --
    sebastian
  • Maxim Nechaev at Nov 14, 2005 at 7:12 am
    Thanks for answers!

    SR> Short answer: Use Local actions and mod_rewrite or a custom rewrite
    SR> plugin.
    What is the best starting point for information about writing custom
    rewrite plugin?


    SR> Not so short answer: Your "forum" controller looks like it wants to
    SR> be a application, which could be deployed as a mod_perl handler or
    SR> FCGI with whatever prefix you want. There is no need to stuff all
    SR> functionality in a single Cat app just because it's possible.
    Is there some official project ideology "What is Catalyst
    Application?", "What is Catalyst Controller?". If i need to create web
    site with "forum" and "chat" it must be two different Catalyst
    Application without any logical connection between them? Catalyst is a
    tool for creating some blocks of site or whole site?

    On CPAN present "Catalyst::Plugin::SubRequest" plugin. From
    documentations i can't understand designation of this module. Maybe it
    may serve as configuration of whole site by dispatching some url
    prefixes to different Controllers or Applications?


    --
    Maxim Nechaev
  • Sebastian Riedel at Nov 14, 2005 at 11:18 am

    Am 14.11.2005 um 07:17 schrieb Maxim Nechaev:

    Thanks for answers!

    SR> Short answer: Use Local actions and mod_rewrite or a custom
    rewrite
    SR> plugin.
    What is the best starting point for information about writing custom
    rewrite plugin?
    perldoc Catalyst::Plugin::WritingPlugins

    SR> Not so short answer: Your "forum" controller looks like it
    wants to
    SR> be a application, which could be deployed as a mod_perl handler or
    SR> FCGI with whatever prefix you want. There is no need to stuff all
    SR> functionality in a single Cat app just because it's possible.
    Is there some official project ideology "What is Catalyst
    Application?", "What is Catalyst Controller?". If i need to create web
    site with "forum" and "chat" it must be two different Catalyst
    Application without any logical connection between them? Catalyst is a
    tool for creating some blocks of site or whole site?
    Both, it's completely up to you, multiple Catalyst apps can also
    share base classes...
    On CPAN present "Catalyst::Plugin::SubRequest" plugin. From
    documentations i can't understand designation of this module. Maybe it
    may serve as configuration of whole site by dispatching some url
    prefixes to different Controllers or Applications?
    It's what it says, a plugin for sub-requests, using external paths
    and not ignoring begin/auto/end..., unlike forward.


    --
    sebastian
  • Bill Moseley at Nov 14, 2005 at 2:04 pm

    On Mon, Nov 14, 2005 at 03:06:41PM +1000, Maxim Nechaev wrote:
    Hi, all.

    Catalyst::Manual::Intro.pod declare "Unrestrained URL-to-Action
    Dispatching" in Catalyst.
    Well, but i think all of dispatching types (Path, Regex, Global,
    Local) badly link up URL and his handler.
    For example, i have some forum Controller, begining with url
    "/forum/". Later, i want move it to "/communication/" or
    "/communication/forum/". What i need to do it?
    As sri points out, use "Local" actions in the controller. And for the
    "default" action for the controller you can now use "Path" with an
    empty path. E.g.:

    package App::C::Forum;

    # handle /forum requests
    sub root : Path {
    ...
    }

    # handle /forum/edit
    sub edit : Local {
    ...
    }

    Then in your templates use the new uri_for method:

    <a href="[% c.uri_for('edit') %]">Edit this item</a>
    <a href="[% c.uri_for('delete') %]">Delete this item</a>

    Then to move the feature to another location you can just move the
    controller and modify its package.


    Sometimes I wonder why the package couldn't default to the name of the
    file relative to the lib dir. Then all it would take is moving the
    controller file.

    --
    Bill Moseley
    moseley@hank.org
  • Johan Lindstrom at Nov 14, 2005 at 2:23 pm

    At 14:09 2005-11-14, Bill Moseley wrote:
    Then in your templates use the new uri_for method:

    <a href="[% c.uri_for('edit') %]">Edit this item</a>
    <a href="[% c.uri_for('delete') %]">Delete this item</a>
    Excellent to have a helper function for this! Me like mucho.

    But isn't this (using GET requests for destructive actions) the same issue
    that the Rails guys encountered with the Google Web Accelerator and the
    shit storm that ended up with?

    For example:
    http://www.loudthinking.com/arc/000454.html
    http://www.loudthinking.com/arc/000455.html
    http://www.loudthinking.com/arc/000529.html
    http://www.loudthinking.com/arc/000530.html


    Anything we can learn from that? Or is it a solved problem in Cat already?


    /J

    -------- ------ ---- --- -- -- -- - - - - -
    Johan Lindstr?m Sourcerer @ Boss Casinos johanl AT DarSerMan.com

    Latest bookmark: "TCP Connection Passing"
    http://tcpcp.sourceforge.net/
    dmoz: /Computers/Programming/Languages/JavaScript/ 12
  • Bill Moseley at Nov 14, 2005 at 2:50 pm

    On Mon, Nov 14, 2005 at 02:28:41PM +0100, Johan Lindstrom wrote:
    At 14:09 2005-11-14, Bill Moseley wrote:
    Then in your templates use the new uri_for method:

    <a href="[% c.uri_for('edit') %]">Edit this item</a>
    <a href="[% c.uri_for('delete') %]">Delete this item</a>
    Excellent to have a helper function for this! Me like mucho.

    But isn't this (using GET requests for destructive actions) the same issue
    that the Rails guys encountered with the Google Web Accelerator and the
    shit storm that ended up with?

    I do something like this in my delete actions:

    sub delete : Local {
    my ( $self, $c, $id, $delete ) = @_;

    return $c->internal_redirect('list', { message => 'Invalid Item Selected' } )
    unless my $item = DB::Item->retrieve( $id );


    unless ( $delete && $c->req->method eq 'POST' ) {
    $c->stash->{template} = 'verify_delete.xhtml';
    $c->stash->{item} = $item;
    return;
    }

    if ( $c->req->parameters->{yes} ) {
    $c->stash->{message} = 'Deleted [' . $item->name . ']';
    $item->delete;
    }

    return $c->internal_redirect('list');
    }

    --
    Bill Moseley
    moseley@hank.org
  • Matt S Trout at Nov 14, 2005 at 7:09 pm

    On Mon, Nov 14, 2005 at 03:06:41PM +1000, Maxim Nechaev wrote:
    Hi, all.

    Catalyst::Manual::Intro.pod declare "Unrestrained URL-to-Action
    Dispatching" in Catalyst.
    Well, but i think all of dispatching types (Path, Regex, Global,
    Local) badly link up URL and his handler.
    For example, i have some forum Controller, begining with url
    "/forum/". Later, i want move it to "/communication/" or
    "/communication/forum/". What i need to do it?
    Add

    sub action_namespace { 'communication/forum' }

    to your Controller class. Any :Local, :LocalRegex and :Path('...') actions
    will move.

    --
    Matt S Trout Specialists in Perl consulting, web development, and
    Technical Director UNIX/Linux systems architecture and automation. Mail
    Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information

    + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedNov 14, '05 at 6:01a
activeNov 14, '05 at 7:09p
posts8
users5
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase