FAQ
I have a requirement to be able to do things like this:

A user creates "actionitems" which are just task notes.
An actionitem might not be associated with a project,
or a meeting, or assigned to another user, etc. Later,
it might be attached to a meeting; then all actionitems
associated with that meeting can be listed; individual items
can be updated, etc. Also, there might be several meetings
associated with a given project. We want to list those,
list the actionitems associated with particular projects,
etc.

I have a lot of this worked out using Chained, but there's a problem.
I've got controller classes like:

C::P::Actionitems
C::P::Meetings
C::P::Users::Profile::Actionitems
C::P::Users::Profile::Meetings
C::P::Users::Profile::Meetings::Actionitems
etc

It gets yukkie fast. I'm looking for a way to, -- as the
documentation says -- "redispatch a chain through any controller
or namespace you want," and I'd certainly like to stay DRY. I need to be
able to mix and match methods, so I can serve URLs like these:

/project/list # self explanatory
/meeting/list # self explanatory
/project/*/meeting/list # meetings associated to a project
/user/*/project/list # projects user is member of
/user/*/actionitem/create # unassociated item
/user/*/actionitem/*/edit # unassociated item
/user/*/meeting/*/actionitem/list # items associated to a meeting
/user/*/meeting/*/actionitem/*/edit # edit a particular meeting's item
/user/*/project/*/meeting/*/actionitem/*/edit # yada yada

In this scenario, actions may be endpoints in some situations, links in
others.
To put it another way, is there a way to have actions like these, and use
Chained to dispatch around?

C::P::Users
C::P::Actionitems
C::P::Meetings
C::P::Projects

Is this even possible to do using Chained? If not, what would be
recommended?


/dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090609/718fdde1/attachment.htm

Search Discussions

  • Devin Austin at Jun 9, 2009 at 6:00 pm

    On Tue, Jun 9, 2009 at 11:55 AM, Dennis Daupert wrote:

    I have a requirement to be able to do things like this:

    A user creates "actionitems" which are just task notes.
    An actionitem might not be associated with a project,
    or a meeting, or assigned to another user, etc. Later,
    it might be attached to a meeting; then all actionitems
    associated with that meeting can be listed; individual items
    can be updated, etc. Also, there might be several meetings
    associated with a given project. We want to list those,
    list the actionitems associated with particular projects,
    etc.

    I have a lot of this worked out using Chained, but there's a problem.
    I've got controller classes like:

    C::P::Actionitems
    C::P::Meetings
    C::P::Users::Profile::Actionitems
    C::P::Users::Profile::Meetings
    C::P::Users::Profile::Meetings::Actionitems
    etc

    It gets yukkie fast. I'm looking for a way to, -- as the
    documentation says -- "redispatch a chain through any controller
    or namespace you want," and I'd certainly like to stay DRY. I need to be
    able to mix and match methods, so I can serve URLs like these:

    /project/list # self explanatory
    /meeting/list # self explanatory
    /project/*/meeting/list # meetings associated to a project
    /user/*/project/list # projects user is member of
    /user/*/actionitem/create # unassociated item
    /user/*/actionitem/*/edit # unassociated item
    /user/*/meeting/*/actionitem/list # items associated to a meeting
    /user/*/meeting/*/actionitem/*/edit # edit a particular meeting's item
    /user/*/project/*/meeting/*/actionitem/*/edit # yada yada

    In this scenario, actions may be endpoints in some situations, links in
    others.
    To put it another way, is there a way to have actions like these, and use
    Chained to dispatch around?

    C::P::Users
    C::P::Actionitems
    C::P::Meetings
    C::P::Projects

    Is this even possible to do using Chained? If not, what would be
    recommended?


    /dennis

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/

    Are you creating plugins for each of those user actions? C::P:: is the
    plugin naming convention. I could have missed something though.

    Anyway, check out this Chained tutorial I've written, it covers the type of
    chaining you want to do. Not quite as in depth as your example, but there
    is a "nested" chain, so I'm sure you could figure it out from there. If
    not, you have the list :-)

    http://www.catalyzed.org/2009/05/chained-the-awesomesauce.html

    hth,

    -dhoss

    --
    Devin Austin
    http://www.codedright.net
    http://www.dreamhost.com/r.cgi?326568/hosting.html - Host with DreamHost!
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090609/49848cf4/attachment.htm
  • Dennis Daupert at Jun 9, 2009 at 9:51 pm

    On Tue, Jun 9, 2009 at 2:00 PM, Devin Austin wrote:
    Are you creating plugins for each of those user actions? C::P:: is the
    plugin naming convention. I could have missed something though.

    Hi Devin,

    No, I'm not creating plugins. You didn't miss something; I did. I'm just
    creating controllers. My bad.

    Anyway, check out this Chained tutorial I've written, it covers the type of
    chaining you want to do. Not quite as in depth as your example, but there
    is a "nested" chain, so I'm sure you could figure it out from there. If
    not, you have the list :-)

    http://www.catalyzed.org/2009/05/chained-the-awesomesauce.html
    You've written a really good and useful article. I wish I'd run into it a
    few months ago. I've spent a lot of time reading up on Chained, and working
    out method flows, so I am at least over the initial shock of the steep (to
    some of us mortals) learning curve. I don't have a "Eureka!" yet, tho. Let
    me see if I can clarify the problem I'm having.

    In many of the examples I've seen, where you have a url like
    /account/*org/*,
    they show a parent controller, and a child controller. For example, on the
    catalyst wiki,
    http://dev.catalyst.perl.org/wiki/gettingstarted/howtos/chainedexamples:

    ==========================================
    package MyApp::Controller::Account;

    # match /account
    sub base :Chained("/") :PathPart("account") :CaptureArgs(0) {}

    # match /account/*
    sub id :Chained("base") :PathPart("") :CaptureArgs(1) {}

    package MyApp::Controller::Account::Org;

    # match /account/org
    sub base :Chained("/account/base") :PathPart("org") :CaptureArgs(0) {}

    # match /account/org/*
    sub id :Chained("base") :PathPart("") :CaptureArgs(1) {}
    ==========================================

    But I have a situation where I need to flow thru methods that aren't tightly
    bound to a parent/child relationship. Or I need to be able to create
    parent/child methods 'on the fly.'

    In the scenario above, /account is anchored to the root url, /. Makes sense,
    you have to start somewhere, right? As a user, I want to create actionitems,
    and since they belong to me, I'm initially ok with a parent User controller
    class in which base is anchored to '/' and a child Actionitems controller
    class. (But that gets me into trouble later...)

    MyApp::User;
    MyApp::User::Actionitem;

    I have my CRUD methods for actionitems in the child class. This is fine for
    'items that are unassociated to meetings or projects. But when I tell the
    'item it now is attached to Meeting 37, and the meeting leader does a search
    on Actionitems people have attached to the meeting, things get complicated.
    Let's say the team leader is user # 16. She logs into her /user/profile,
    clicks on 'meetings,' selects meeting 37, and does a search for actionitems
    people have sent to that meeting. Now we need a method flow like this:

    /user/16/meeting/37/actionitem/list

    The list displays. Each 'item has links to edit, delete, reassign, yada
    yada.
    But my CRUD methods for actionitems are all located in
    MyApp::User::Actionitem. I haven't figured out how to flow thru the User
    class to get $user_obj, then Meeting class to pick up $meeting_obj, and
    finally Actionitem class to get you know what.

    And when we throw /projects/ into the mix, we get even more complicated.

    Have I succeeded in making the issue clear? Or have I convinced you I'm
    completely insane? (Or maybe both...)

    /dennis
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090609/5ac3b0c8/attachment.htm
  • Peter Karman at Jun 9, 2009 at 10:14 pm

    Dennis Daupert wrote on 6/9/09 4:51 PM:
    MyApp::User;
    MyApp::User::Actionitem;

    I have my CRUD methods for actionitems in the child class. This is fine for
    'items that are unassociated to meetings or projects. But when I tell the
    'item it now is attached to Meeting 37, and the meeting leader does a search
    on Actionitems people have attached to the meeting, things get complicated.
    Let's say the team leader is user # 16. She logs into her /user/profile,
    clicks on 'meetings,' selects meeting 37, and does a search for actionitems
    people have sent to that meeting. Now we need a method flow like this:

    /user/16/meeting/37/actionitem/list
    have you looked at how CatalystX::CRUD::Controller does this? It supports
    arbitrary relationship names like you are describing.

    --
    Peter Karman . http://peknet.com/ . peter@peknet.com
  • Dennis Daupert at Jun 10, 2009 at 2:46 am

    On Tue, Jun 9, 2009 at 6:14 PM, Peter Karman wrote:
    have you looked at how CatalystX::CRUD::Controller does this? It supports
    arbitrary relationship names like you are describing.

    --
    Peter Karman . http://peknet.com/ . peter@peknet.com
    Ah, no, I haven't. I'll dig into it and have a look. Searching on CPAN... I
    notice the author's name, "Peter Karman" -- any relation? ;-)

    Thanks for the tip!

    /dennis
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090609/8447f46d/attachment.htm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 9, '09 at 5:55p
activeJun 10, '09 at 2:46a
posts5
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase