[Catalyst] Chained actions question
leonard.a.jaffe at jpmchase.com
leonard.a.jaffe at jpmchase.com
Tue Aug 29 21:38:42 CEST 2006
Matt S Trout <dbix-class at trout.me.uk> 08/25/2006 04:23 PM wrote:
> leonard.a.jaffe at jpmchase.com wrote:
> >
> > I need to be able to handle URLs like these:
> >
> > 2) /report/2006/08/22 - likewise for
> > master(2006-08-22) and all of its detail children
> > 3) /report/add/ - inserts a new
> > master record for today's date
> >
> > 5) /report/2006/08/22/add - inserts an issue for
> > master(2006/08/22)
> > [ likewise for update of issue data]
> >
> > 7) /report/2006/08/22/edit/3 - displays the screen for
> > master(2006/08/22) with issue(3) loaded into the issued add/edit form.
> >
> > Any hints would be greatly appreciated.
>
> sub base :Chained('/') :PathPart('report') :CaptureArgs(0)
>
> sub master_by_id :Chained('base') :PathPart('') :CaptureArgs(1)
>
> sub master_by_date :Chained('base') :PathPart('') :CaptureArgs(3)
>
> then you'd set up a controller base-class for your actual actions with
their
> own 'base' action, and declare one as chained off of master_by_id and
the
> other off of master_by_date
>
> That might seem like unnecessary duplication, but it's -really- handy in
terms
> of doing uri_for($action, ...) because it allows you to explicitly
specify
> which path you're following.
Thanks Matt!
I decided to bag the idea of using the master record id, and only use the
report date to specify the master record. That simplified it a little.
The I realized, that in my little world, the following are all valid:
/dailystatusrpt/view
/dailystatusrpt/2006/view
/dailystatusrpt/2006/08/view
/dailystatusrpt/2006/08/28/view
I did not quite follow your reasoning for using multiple class files, so
I've
proceeded with the "one class to rule them all" design. I've listed my
action
signatures below, in case anybody wants to puzzle out how these chained
actions
work together for me. I say "puzzle" with love. I really like how this is
turning out. I can one action that is responsible for getting my master
record,
and know that it will run, and not have to repeatedly write calls to
get_master()
at every end-point action.
So the list of signatures below, implements the four actions above, and
/dailystatusrpt/2006/08/28/issue/add
in a few moments I'll be implementing /dailystatusrpt/*/*/*/issue/*/edit
and /dailystatusrpt/*/*/*/issue/*/update
sub base :Chained('/') PathPart('') CaptureArgs(0) {
sub drpt : Chained('base') PathPart('dailystatusrpt') CaptureArgs(0) {
sub view_drpt :Chained('drpt') PathPart('view') Args(0) {}
sub drpt_year : Chained('base') PathPart('dailystatusrpt') CaptureArgs(1)
{
sub year_view :Chained('drpt_year') PathPart('view') Args(0) {}
sub drpt_month : Chained('base') PathPart('dailystatusrpt') CaptureArgs(2)
{
sub view_month :Chained('drpt_month') PathPart('view') Args(0) {}
sub drpt_day : Chained('base') PathPart('dailystatusrpt') CaptureArgs(3) {
sub day_view :Chained('drpt_day') PathPart('view') Args(0) {
sub create_drpt :Chained('drpt_day') PathPart('create') Args(0) {
sub issue : Chained('drpt_day') PathPart CaptureArgs(0) {}
sub create_issue : Chained('issue') PathPart('add') Args(0) {
Len.
-----------------------------------------
This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and
any attachments are believed to be free of any virus or other
defect that might affect any computer system into which it is
received and opened, it is the responsibility of the recipient to
ensure that it is virus free and no responsibility is accepted by
JPMorgan Chase & Co., its subsidiaries and affiliates, as
applicable, for any loss or damage arising in any way from its use.
If you received this transmission in error, please immediately
contact the sender and destroy the material in its entirety,
whether in electronic or hard copy format. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060829/bc37773c/attachment.htm
More information about the Catalyst
mailing list