Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Is it possible somehow to mix and match path parts using Chained?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


ddaupert at gmail

Jun 9, 2009, 10:55 AM

Post #1 of 5 (564 views)
Permalink
Is it possible somehow to mix and match path parts using Chained?

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


devin.austin at gmail

Jun 9, 2009, 11:00 AM

Post #2 of 5 (530 views)
Permalink
Re: Is it possible somehow to mix and match path parts using Chained? [In reply to]

On Tue, Jun 9, 2009 at 11:55 AM, Dennis Daupert <ddaupert[at]gmail.com> 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[at]lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst[at]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!


ddaupert at gmail

Jun 9, 2009, 2:51 PM

Post #3 of 5 (526 views)
Permalink
Re: Is it possible somehow to mix and match path parts using Chained? [In reply to]

On Tue, Jun 9, 2009 at 2:00 PM, Devin Austin <devin.austin[at]gmail.com> 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


peter at peknet

Jun 9, 2009, 3:14 PM

Post #4 of 5 (525 views)
Permalink
Re: Is it possible somehow to mix and match path parts using Chained? [In reply to]

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[at]peknet.com

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


ddaupert at gmail

Jun 9, 2009, 7:46 PM

Post #5 of 5 (519 views)
Permalink
Re: Is it possible somehow to mix and match path parts using Chained? [In reply to]

On Tue, Jun 9, 2009 at 6:14 PM, Peter Karman <peter[at]peknet.com> 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[at]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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.