Slash Boxes
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

use Perl Log In

Log In

[ Create a new account ]

jk2addict (4946)

  (email not shown publicly)
AOL IM: chrislaco (Add Buddy, Send Message)
Yahoo! ID: (Add User, Send Message)

Journal of jk2addict (4946)

Friday January 11, 2008
02:49 PM

Catalyst Chained Hack

[ #35367 ]

With mst pointing in the correct direction [as usual], this is a little hack I have to make Chained('../method') possible.

This is mostly for cases where I want to have Controller::Foo::Child chained off of Controller::Foo, but I feel naughty about hardcoding Chained('/foo/method') in Foo::Child, esp if both of those classes are subclasses, so the name can follow long.

sub _parse_Chained_attr {
    my ($self, $c, $name, $value) = @_;
    if ($value && $value =~ /\.\.\//) {
        ## this is a friggin hack because I don't know how to have
        ## Path::Class eval ../ for me
        local $URI::ABS_REMOTE_LEADING_DOTS = 1;
        $value = URI->new(
            Path::Class::Dir->new($self->action_namespace, $value)->as_foreign('Unix')->stringify
    return Chained => $value || $self->action_namespace;

That's ugly, but it works. Now, does anyone know how to make Path::Class evaluate ../ in paths? I resoted to that URI hack, but in the end, it did what I needed it to do.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • $value=dir($value)->absolute($self->action_namespace)

    If action_namespace doesn't start with '/':