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

John Napiorkowski jjn1056 at yahoo.com
Tue Jan 23 14:47:09 GMT 2007


--- Michael Reece <mreece at vinq.com> wrote:

> 
> 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?

It's in:
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7006/lib/Catalyst/Base.pm

Catalyst:Base, which is the base class to Controllers.
 This get's you the Action Object for the named
action.

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

Yeah, I had this trouble as well.  You need to get
used to checking the source a lot, that will certainly
help.

> 
> 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 ..

I'm not so familiar with "get_action_by_path", maybe
someone else on the list will be able to fill in
details.  I'm not sure it is a recommended way to get
URIs out of actions though.  

AFA trouble using this with Root.pm, this should be
just work, since you are using the private names for
stuff.  I'm sure I've done
$c->uri_for($c->controller('Root')->action_for('logout'));
or similar.  I'll check.

--john

> 
> 
> 
> 
> 
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo:
> http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
>
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
> 



 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097



More information about the Catalyst mailing list