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

Mailing List Archive: Catalyst: Dev
Proposed patch for ActionClass attribute
 

Index | Next | Previous | View Flat


brucem at dynamicrange

Apr 3, 2009, 11:19 AM


Views: 625
Permalink
Proposed patch for ActionClass attribute

I implemented application-specific an Application-specific action, and
found the "MyAction" construct to be a little odd. So I took a run at
extending the ActionClass parser to look for a local app version
("MyApp::Action::Foo") first, then to fall back to the Catalyst
version ("Catalyst::Action::Foo") if that's not present. You can still
use "+My::Full::Path" to force a particular selection (such as to skip
over an app version for some reason).

Is there a reason that this wasn't tried before?

I hope this helps. I'd appreciate feedback, and can provide the tests
and doc if this is interesting enough to proceed. Catalyst is a neat
system, and I appreciate the hard work of those who have made it what
it is today.

Cheers,

Bruce

diff -rc /Library/Perl/5.8.8/Catalyst/Controller.pm Catalyst/
Controller.pm
*** /Library/Perl/5.8.8/Catalyst/Controller.pm 2009-04-02
14:07:54.000000000 -0700
--- Catalyst/Controller.pm 2009-04-03 11:13:10.000000000 -0700
***************
*** 318,325 ****

sub _parse_ActionClass_attr {
my ( $self, $c, $name, $value ) = @_;
! unless ( $value =~ s/^\+// ) {
! $value = join('::', $self->_action_class, $value );
}
return ( 'ActionClass', $value );
}
--- 318,344 ----

sub _parse_ActionClass_attr {
my ( $self, $c, $name, $value ) = @_;
! if ( substr($value,0,1) eq '+' )
! {
! $value = substr($value,1);
! }
! else
! {
! eval {
! # Check our app first...
! my $appclass = Catalyst::Utils::class2appclass($self);
!
! Catalyst::Utils::ensure_class_loaded( "$
{appclass}::Action::${value}" );
! $value = "${appclass}::Action::${value}";
! # $c->log->debug("Succeeded in loading $value");
! };
! if ( $@ )
! {
! # We take any error to mean "class doesn't exist", so
fall back
! # to one in the Catalyst hierarchy.
! $value = join('::', $self->_action_class, $value );
! # $c->log->debug("Failed app version, falling back to
$value");
! }
}
return ( 'ActionClass', $value );
}

---
Bruce McKenzie
brucem[at]dynamicrange.com

Subject User Time
Proposed patch for ActionClass attribute brucem at dynamicrange Apr 3, 2009, 11:19 AM
    Re: Proposed patch for ActionClass attribute bobtfish at bobtfish Apr 18, 2009, 6:46 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.