Okay, more info! I attached a text file which is what I see when catalyst starts up. It has the action paths, etc. Also I appended to that what I get when I actually try to run it. I also attached the actual controller module that I wrote that is making all this happen, just in case eyeballing that is useful.
The thing that is weird is that if I just take out all
the PathParts and let the Chain revert to the default
PathPart name it all just works fine, although I don't
get the URLs I want.
Let me know what you think. I know Chaining is quite
new to Catalyst so maybe best practices are still
emerging. Personally I really think it's one of the
things that is great about Catalyst, makes it really
appeal to the code idealist in me :)
--john
--- Matt S Trout <[EMAIL PROTECTED]> wrote:
> John Napiorkowski wrote:
> > I've notices what I think is somewhat strange
> behavior
> > in a chain I've created, although as usual it
> might
> > just be my ignorance. Here's is a skeleton of the
> > chain I made:
> >
> > package myapp::Controller::Feedrolls
> >
> > sub feedrolls :Chained('/') CaptureArgs(0){}
> >
> > sub feedrolls_all :Chained('feedrolls')
> PathPart('')
> > Args(0) {}
> >
> > sub feedroll :Chained('feedrolls') PathPart('')
> > CaptureArgs(1) { my ($self, $c, $captured) = @_; }
> >
> > sub feedroll_all :Chained('feedroll') PathPart('')
> > Args(0) {}
> >
> > When I run catalyst I get a mapping like this:
> >
> > (1) /feedrolls/*
> > (2) /feedrolls
> >
> > (1) chains from feedrolls to feedroll to
> feedroll_all
> > and (2) chains from feedrolls to feedrolls_all.
> >
> > Okay so far so good. However when I try to call
> the
> > action through the browser at
> > "http://localhost/feedrolls" I get an error about
> the
> > $captured variable being undefined, which is
> strange
> > to me since I am thinking that to get to the
> > containing sub I need to use an action link
> > "/feedrolls/[feedroll_id]". When I look at the
> debug
> > output to see what is getting called I can see
> that
> > indee that chain is going from feedrolls to
> feedroll
> > to feedroll_all instead of from feedrolls to
> feedrolls
> > all.
> >
> > What is even stranger is that if I change the sub:
> >
> > sub feedroll :Chained('feedrolls') PathPart('')
> > CaptureArgs(1) { my ($self, $c, $captured) = @_; }
> >
> > to
> >
> > sub feedroll :Chained('feedrolls') PathPart('')
> > Args(1) { my ($self, $c, $captured) = @_; }
> >
> > and handle all the processing there instead of the
> way
> > I outlined it above, everything works as expected.
> >
> > So there seems to be something strange here, since
> > merely terminating the chain one sub earlier
> changes
> > the ways things get called quite a bit.
> >
> > So... Can anyone spot if there is something wrong
> in
> > the way I am doing this?
>
> Not without the startup debug output for your app
> showing the path part
> dispatch table ...
>
> MORE INFORMATION! MORE INFORMATION! MORE
> INFORMATION!
>
> (MORE CAFFEINE! :)
>
> --
> Matt S Trout Offering custom
> development, consultancy and support
> Technical Director contracts for Catalyst,
> DBIx::Class and BAST. Contact
> Shadowcat Systems Ltd. mst (at)
> shadowcatsystems.co.uk for more information
>
> + Help us build a better perl ORM:
> http://dbix-class.shadowcatsystems.co.uk/ +
>
> _______________________________________________
> List: [email protected]
> Listinfo:
> http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
>
http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com [debug] Loaded Private actions: .----------------------+--------------------------------------+--------------. | Private | Class | Method | +----------------------+--------------------------------------+--------------+ | /default | services::Controller::Root | default | | /end | services::Controller::Root | end | | /feedrolls/feedroll- | services::Controller::feedrolls | feedroll_all | | _all | | | | /feedrolls/feedrolls | services::Controller::feedrolls | feedrolls | | /feedrolls/feedroll- | services::Controller::feedrolls | feedrolls_a- | | s_all | | ll | | /feedrolls/begin | services::Controller::feedrolls | begin | | /feedrolls/feedroll | services::Controller::feedrolls | feedroll | '----------------------+--------------------------------------+--------------' [debug] Loaded Path Part actions: .-------------------------------------+--------------------------------------. | Path Spec | Private | +-------------------------------------+--------------------------------------+ | /feedrolls/* | /feedrolls/feedrolls (0) | | | -> /feedrolls/feedroll (1) | | | => /feedrolls/feedroll_all | | /feedrolls | /feedrolls/feedrolls (0) | | | => /feedrolls/feedrolls_all | '-------------------------------------+--------------------------------------' [info] services powered by Catalyst 5.7001 [... When trying to access http://localhost/feedrolls ...] Use of uninitialized value in concatenation (.) or string at /mnt/hgfs/talentspace/development/services/script/../lib/services/Controller/feedrolls.pm line 130.[info] *** Request 1 (0.010/s) [7735] [Tue Sep 5 09:50:57 2006] *** [debug] "GET" request for "feedrolls" from "127.0.0.1" [debug] Path is "/feedrolls/feedroll_all" [debug] Couldn't find the specified feed_id of [debug] There was an error or redirect status code, skipping page generation. [error] Caught exception in services::Controller::feedrolls->feedroll_all "Can't call method "feeds" on an undefined value at /mnt/hgfs/talentspace/development/services/script/../lib/services/Controller/feedrolls.pm line 154." [info] Request took 1.073014s (0.932/s) .----------------------------------------------------------------+-----------. | Action | Time | +----------------------------------------------------------------+-----------+ | /feedrolls/begin | 0.004660s | | /feedrolls/feedrolls | 0.004727s | | /feedrolls/feedroll | 0.124365s | | /feedrolls/feedroll_all | 0.001934s | | /end | 0.000276s | '----------------------------------------------------------------+-----------' [... Here is what the browser says ...] Caught exception in services::Controller::feedrolls->feedroll_all "Can't call method "feeds" on an undefined value at /mnt/hgfs/talentspace/development/services/script/../lib/services/Controller/feedrolls.pm line 154." Stack Trace Package Line File services::Controller::feedrolls 154 /mnt/hgfs/talentspace/development/services/lib/services/Controller/feedrolls.pm 151: my $feedroll :Stash; 152: my $xml_atom_object :Stash; 153: 154: my $feeds = $feedroll->feeds; 155: 156: $xml_atom_object->id($c->uri_for($c->action, @{$c->request->arguments})); 157: $xml_atom_object->title($feedroll->title);
feedrolls.pm
Description: 1084352052-feedrolls.pm
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
