[Catalyst] Re: Calling Controller Methods from inside begin or auto.
Aristotle Pagaltzis
pagaltzis at gmx.de
Thu Oct 1 03:11:40 GMT 2009
* Bill Moseley <moseley at hank.org> [2009-09-30 20:10]:
> The problem there was then the action's auto() and begin()
> methods were not run with the user logged in, which was
> important for other reasons.
Ah. The only `begin`, `end` and `default` actions I have are in
my root controller, and the only responsibilities they have are
setting up and tearing down auth and rendering the stash.
Everything else is done via Chained: all other controllers have
sub base : Chained PathPart('whatever') ... { ... }
even if it is empty (which is the case as often as not), and all
actions in each controller chain off its `base` action. That
`base` may itself chain off another action in another controller
instead of `/`.
With this structure, having `auto` etc run before or after auth
or whatever is never an issue. I also do all my auth checks
piecemeal along the chain, thus, without complicated chains of
conditionals in my code, dispatch determines for me how
specifically to perform a complex auth check. And if I need to
extract logic from several actions without affecting the URI
structure I can add a `PathPart('') CaptureArgs(0)` action into
the chain and voilà.
I really enjoy working with this structure. It’s declarative and
very DRY, no hairy logic, clear, simple, explicit. I ♥ Chained.
Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Catalyst
mailing list