Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • You might want to look at chained actions: Catalyst::DispatchType::Chained [cpan.org].

    That gives you an easy way to have URIs like

    /user/$userid/entries/$year/$month

    And you can set the URI via:

    my $action = $ctx->controller('Foo')->action_for('edit');
    my $uri = $ctx->uri_for($action, \@captures, @arguments);

    What goes into captures and what into arguments depends on your application design.

    While the version of uri_for() that uses an action object instead of a string seems a bit more work, it gives you one hug

    --
    Ordinary morality is for ordinary people. -- Aleister Crowley
  • From MyApp.pm:

    sub uri_for {
        my $c = shift;
        my ( $path ) = @_;

        if ( not Scalar::Util::blessed( $path ) and 'ARRAY' eq ref $path ) {
            my $action_path = shift @$path;
            unshift @_, $action_cache->{ $action_path } ||= $c->dispatcher->get_action_by_path( $action_path );
            $path = $_[0];
        }

        return URI::WithBase::Rel->new( $c->NEXT::uri_for( @_ ), $c->req-

    • Woops, that would be:

      sub uri_for {
          my $c = shift;
          my ( $path ) = @_;

          if ( not Scalar::Util::blessed( $path ) and 'ARRAY' eq ref $path ) {
              my $action_path = shift @$path;
              unshift @_, $c->dispatcher->get_action_by_path( $action_path );
              $path = $_[0];
          }

          return URI::WithBase::Rel->new( $c->NEXT::uri_for( @_ ), $c->req->uri );
      }

      (The actual method i