[Catalyst] Operation "eq": no method found, ... Dispatcher.pm line 377

Michael Reece mreece at vinq.com
Mon Jan 22 22:34:17 GMT 2007


On Jan 22, 2007, at 1:30 PM, John Napiorkowski wrote:

>
> --- Michael Reece <mreece at vinq.com> wrote:
>
>> i am getting intermittent errors (under mod_perl;
>> Catalyst version
>> 5.7003) from $c->dispatcher->uri_for_action:
>>
>> Operation "eq": no method found, left argument in
>> overloaded package
>> URI::_generic, right argument has no overloaded
>> magic at /usr/local/
>> lib/perl5/site_perl/5.8.8/Catalyst/Dispatcher.pm
>> line 377
>>
>> sub uri_for_action {
>>      my ( $self, $action, $captures) = @_;
>>      $captures ||= [];
>>      foreach my $dispatch_type ( @{
>> $self->dispatch_types } ) {
>>          my $uri = $dispatch_type->uri_for_action(
>> $action, $captures );
>>          return( $uri eq '' ? '/' : $uri )	# line
>> 377
>>              if defined($uri);
>>      }
>>      return undef;
>> }
>>
>>
>> i am calling $c->dispatcher->uri_for_action like so:
>>
>>      my $action =
>> $c->dispatcher->get_action_by_path($path);
>>      unless ($action) {
>>          $c->log->error("uri_to cannot
>> get_action_by_path($path)");
>>          return undef;
>>      }
>>
>>      my @action_args = (defined $snippets) ?
>> @$snippets : ();
>>      my $uri =
>> $c->dispatcher->uri_for_action($action,
>> @action_args);
>>      unless ($uri) {
>>          $c->log->error("uri_to cannot find
>> uri_for_action $action");
>>          return undef;
>>      }
>>
>>
>> any ideas?
>>
>> ---
>> michael reece :: software engineer ::
>> mreece at vinq.com
>
> Hi,
>
> This may not help you at all but I don't think you if
> all you want is the URI for a given action that this
> is the method to use.  Typically I use the $c->uri_for
> and controller->action_for methods.  This works pretty
> well for me.
>
> my $uri =
> $c->uri_for($c->controller(xxx)->action_for('action
> private name');
>
> If you just need the uri for an action in the current
> controller and action you can make it even shorter:
>
> my $uri = $c->uri_for($c->action);
>
> or for a different action in the same controller:
>
> my $uri =
> $c->uri_for($c->controller->action_for('action name');
>
> I think there are even easier ways to do this, might
> want to search the archives.
>
> Can you give me a few more details about your use case
> and setup and then maybe I can understand what the
> best way to solve your problem is.
>
> --John
>

can you tell me where $c->controller->action_for is documented?

http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/Catalyst/ 
Controller.pm is rather blank.

my specific use case here is

   my $uri = $c->uri_to('/some/controller/method', @path_args, {% 
query_args}, [@snippets]);

i convert the $path '/some/controller/method' to an action using $c- 
 >dispatcher->get_action_by_path, and then get the uri for the  
$action via $c->dispatcher->uri_for_action as mentioned at

http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/ 
Catalyst.pm#%24c-%3Euri_for(_%24path%2C_%40args%3F%2C_%5C% 
25query_values%3F_)

i will take a look at action_for and see if it will do what i want.   
looks like i would first have to transform '/some/controller/method'  
into 'Some::Controller' + 'method', which would work for most cases,  
except when the controller namespace differs from the package  
namespace (ie, Controller/Root.pm) .. those contortions are what  
makes $c->dispatcher->get_action_by_path attractive, but the question  
remains why that sometimes returns $actions (with truthiness) that  
cause uri_for_action($action) to die ..







More information about the Catalyst mailing list