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

Mailing List Archive: Catalyst: Users

Another RFC. $c->call()

 

 

First page Previous page 1 2 Next page Last page  View All Catalyst users RSS feed   Index | Next | Previous | View Threaded


marcus at thefeed

Apr 12, 2006, 5:16 AM

Post #1 of 29 (3109 views)
Permalink
Another RFC. $c->call()

Please check out

http://marcusramberg.livejournal.com/12301.html

Comments welcome.

--
With regards
Marcus Ramberg


claco at chrislaco

Apr 12, 2006, 5:43 AM

Post #2 of 29 (3057 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Marcus Ramberg wrote:
> Please check out
>
> http://marcusramberg.livejournal.com/12301.html
>
> Comments welcome.
>
> --
> With regards
> Marcus Ramberg

vote +1.

I'm surprised this hasn't been addressed sooner. It seems like a common
problem, esp. in CRUD.

-=Chris
Attachments: signature.asc (0.18 KB)


dom at idealx

Apr 12, 2006, 5:52 AM

Post #3 of 29 (3056 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marcus Ramberg a écrit :

> Please check out
>
> http://marcusramberg.livejournal.com/12301.html
>
> Comments welcome.

I side with the first blog comment on the naming issues. Also, the
"redispatch" version should be made to throw exceptions instead of
returning, and possibly should not return even in case of success. So
how about this:

Name Effect Exceptions

->call() Invokes controller are trapped
w/o changing $c->action

->forward() ditto ditto

->redispatch() Invokes controller, changing are fatal from
$c->action caller's POV

- --
Dominique QUATRAVAUX Ingénieur senior
01 44 42 00 08 IDEALX

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEPPgDMJAKAU3mjcsRAthgAJ9eZsHajKV3lZfx7s7sAqJDq1vvvACfTt+R
ss5y31hSaP8iG7VYHSFMoo0=
=ndLQ
-----END PGP SIGNATURE-----



_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


moseley at hank

Apr 12, 2006, 6:41 AM

Post #4 of 29 (3061 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On Wed, Apr 12, 2006 at 02:16:33PM +0200, Marcus Ramberg wrote:
> Please check out
>
> http://marcusramberg.livejournal.com/12301.html

Great. Although I think "call" sounds like a method call, when it's
more like a forward, except where you really mean it.

As I commented on #catalyst, I currently use the SubRequest plugin to
do this, which is a bit overkill.

return $c->internal_redirect( 'list', { message => 'Invalid id' } )
unless $self->valid_id( $id );

but that's better reserved for a real subrequest. Pre coffee so not
much help. $c->send('list')? $c->redispatch('list')?


--
Bill Moseley
moseley [at] hank


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


pagaltzis at gmx

Apr 12, 2006, 8:06 AM

Post #5 of 29 (3040 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

* Dominique Quatravaux <dom [at] idealx> [2006-04-12 14:55]:
> So how about this:
>
> Name Effect Exceptions
>
> ->call() Invokes controller are trapped
> w/o changing $c->action
>
> ->forward() ditto ditto
>
> ->redispatch() Invokes controller, changing are fatal from
> $c->action caller's POV

+1

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


john.lifsey at nrl

Apr 12, 2006, 10:28 AM

Post #6 of 29 (3045 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Bill Moseley wrote:
> return $c->internal_redirect( 'list', { message => 'Invalid id' } )
> unless $self->valid_id( $id );
>
> but that's better reserved for a real subrequest. Pre coffee so not
> much help. $c->send('list')? $c->redispatch('list')?
>
>
>

Might be bike shedding here but I like send/go/hail something of that
nature. Redispatch is a lot to type with lazy programmer fingers.



_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


nothingmuch at woobling

Apr 12, 2006, 10:35 AM

Post #7 of 29 (3047 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On Wed, Apr 12, 2006 at 14:28:10 -0400, John Lifsey - Contractor - wrote:

> Might be bike shedding here but I like send/go/hail something of that
> nature. Redispatch is a lot to type with lazy programmer fingers.

Type it once, then use autocompletion. =)

--
Yuval Kogman <nothingmuch [at] woobling>
http://nothingmuch.woobling.org 0xEBD27418


dbix-class at trout

Apr 12, 2006, 10:35 AM

Post #8 of 29 (3033 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Marcus Ramberg wrote:
> Please check out
>
> http://marcusramberg.livejournal.com/12301.html

The more I think about it the more I'd just like

$c->action('/foo/bar');

to go away and find that action, set $c->action to that if it exists, or die
screaming otherwise.

--
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/ +

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


john.lifsey at nrl

Apr 12, 2006, 11:24 AM

Post #9 of 29 (3039 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Matt S Trout wrote:
> The more I think about it the more I'd just like
>
> $c->action('/foo/bar');
>
> to go away and find that action, set $c->action to that if it exists, or die
> screaming otherwise.
>
>
Second.
Attachments: smime.p7s (3.99 KB)


mdorman at tendentious

Apr 12, 2006, 11:45 AM

Post #10 of 29 (3053 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Matt S Trout <dbix-class [at] trout> writes:
> Marcus Ramberg wrote:
>> Please check out
>>
>> http://marcusramberg.livejournal.com/12301.html
>
> The more I think about it the more I'd just like
>
> $c->action('/foo/bar');
>
> to go away and find that action, set $c->action to that if it exists, or die
> screaming otherwise.

I implemented a not-dissimilar idea as a plugin for an app and called
it "continue", but I think "action" is a fine name.

Mike

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


sri at oook

Apr 12, 2006, 11:50 AM

Post #11 of 29 (3047 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

12.04.2006 20:24 John Lifsey - Contractor -:

> Matt S Trout wrote:
>> The more I think about it the more I'd just like
>>
>> $c->action('/foo/bar');
>>
>> to go away and find that action, set $c->action to that if it
>> exists, or die screaming otherwise.
>>
>>
> Second.

++


--
sebastian


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


dbix-class at trout

Apr 12, 2006, 11:58 AM

Post #12 of 29 (3046 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Michael Alan Dorman wrote:
> Matt S Trout <dbix-class [at] trout> writes:
>> Marcus Ramberg wrote:
>>> Please check out
>>>
>>> http://marcusramberg.livejournal.com/12301.html
>> The more I think about it the more I'd just like
>>
>> $c->action('/foo/bar');
>>
>> to go away and find that action, set $c->action to that if it exists, or die
>> screaming otherwise.
>
> I implemented a not-dissimilar idea as a plugin for an app and called
> it "continue", but I think "action" is a fine name.

I suspect that's something different.

For a start, 'continue' isn't already an accessor method on $c ...

--
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/ +

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


moseley at hank

Apr 12, 2006, 4:38 PM

Post #13 of 29 (3047 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On Wed, Apr 12, 2006 at 06:35:33PM +0100, Matt S Trout wrote:
> Marcus Ramberg wrote:
> > Please check out
> >
> > http://marcusramberg.livejournal.com/12301.html
>
> The more I think about it the more I'd just like
>
> $c->action('/foo/bar');
>
> to go away and find that action, set $c->action to that if it exists, or die
> screaming otherwise.

And $c->action->namespace would still work.

--
Bill Moseley
moseley [at] hank


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


dbix-class at trout

Apr 12, 2006, 4:52 PM

Post #14 of 29 (3033 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Bill Moseley wrote:
> On Wed, Apr 12, 2006 at 06:35:33PM +0100, Matt S Trout wrote:
>> Marcus Ramberg wrote:
>>> Please check out
>>>
>>> http://marcusramberg.livejournal.com/12301.html
>> The more I think about it the more I'd just like
>>
>> $c->action('/foo/bar');
>>
>> to go away and find that action, set $c->action to that if it exists, or die
>> screaming otherwise.
>
> And $c->action->namespace would still work.

That would be the general idea, yes :)

Bugger, everybody seems in favour. Does that mean I'm going to have to
implement it?

--
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/ +

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


marcus at thefeed

Apr 13, 2006, 3:08 AM

Post #15 of 29 (3033 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On 4/13/06, Matt S Trout <dbix-class [at] trout> wrote:
> That would be the general idea, yes :)
>
> Bugger, everybody seems in favour. Does that mean I'm going to have to
> implement it?

Would it also work like forward ?

$c->action('/some/action'); # forwards to /some/action and sets $c->action ?

If so I'm all for, and you get to implement it ;-)

--
With regards
Marcus Ramberg

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


moseley at hank

Apr 13, 2006, 6:01 AM

Post #16 of 29 (3026 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On Thu, Apr 13, 2006 at 12:52:53AM +0100, Matt S Trout wrote:
> Bill Moseley wrote:
> > On Wed, Apr 12, 2006 at 06:35:33PM +0100, Matt S Trout wrote:
> >> Marcus Ramberg wrote:
> >>> Please check out
> >>>
> >>> http://marcusramberg.livejournal.com/12301.html
> >> The more I think about it the more I'd just like
> >>
> >> $c->action('/foo/bar');

Wouldn't a verb be better?

--
Bill Moseley
moseley [at] hank


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


dbix-class at trout

Apr 13, 2006, 7:36 AM

Post #17 of 29 (3037 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

Marcus Ramberg wrote:
> On 4/13/06, Matt S Trout <dbix-class [at] trout> wrote:
>> That would be the general idea, yes :)
>>
>> Bugger, everybody seems in favour. Does that mean I'm going to have to
>> implement it?
>
> Would it also work like forward ?
>
> $c->action('/some/action'); # forwards to /some/action and sets $c->action ?
>
> If so I'm all for, and you get to implement it ;-)

No, you'd do it in an auto() and then Catalyst would dispatch to /some/action
instead of what it was originally going to dispatch to.

--
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/ +

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


marcus at thefeed

Apr 13, 2006, 12:06 PM

Post #18 of 29 (3057 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On 4/13/06, Matt S Trout <dbix-class [at] trout> wrote:
>
> Marcus Ramberg wrote:
> > On 4/13/06, Matt S Trout <dbix-class [at] trout> wrote:
> >> That would be the general idea, yes :)
> >>
> >> Bugger, everybody seems in favour. Does that mean I'm going to have to
> >> implement it?
> >
> > Would it also work like forward ?
> >
> > $c->action('/some/action'); # forwards to /some/action and sets
> $c->action ?
> >
> > If so I'm all for, and you get to implement it ;-)
>
> No, you'd do it in an auto() and then Catalyst would dispatch to
> /some/action
> instead of what it was originally going to dispatch to.



This does not match the common use case for this, imo. You usually want to
do something like
do_edit, and then forward / detach / call / whatever edit, and have Catalyst
act as if you called
edit from that point on.

--
With regards
Marcus Ramberg


acid06 at gmail

Apr 13, 2006, 6:15 PM

Post #19 of 29 (3041 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On 4/13/06, Marcus Ramberg <marcus [at] thefeed> wrote:
> This does not match the common use case for this, imo. You usually want to
> do something like
> do_edit, and then forward / detach / call / whatever edit, and have
> Catalyst act as if you called
> edit from that point on.

Agreed.
But I also think that $c->action('whatever') doesn't *look* like it's
forwarding anywhere else. But maybe that's just because I'm already
used to it. But maybe a verb really would be better.

I've always found $c->forward()'s behaviour of not changing the action
rather counter-intuitive during my first days with Catalyst.
Eventually, I got used to it, though.

-Nilson Santos F. Jr.

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


sri at oook

Apr 13, 2006, 6:34 PM

Post #20 of 29 (3026 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

What about:

$c->action('/foo/bar')->forward;
$c->action('/foo/bar')->detach;

or (suggested by mst):


$c->forward( $c->action('/foo/bar') );
$c->detach( $c->action('/foo/bar') );


--
sebastian


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


acid06 at gmail

Apr 13, 2006, 7:56 PM

Post #21 of 29 (3044 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On 4/13/06, Sebastian Riedel <sri [at] oook> wrote:
> $c->action('/foo/bar')->forward;
> $c->action('/foo/bar')->detach;
>
> or (suggested by mst):
>
> $c->forward( $c->action('/foo/bar') );
> $c->detach( $c->action('/foo/bar') );

I really think that the best solution would be something not backwards
compatible if that's something reasonable (maybe provide
backwards-compatibility through a plugin).

$c->call('foo'): would do what $c->forward('foo') does today
$c->forward('foo'): would be just like $c->call('foo') but would also
change the action

$c->dispatch('foo'): would do what $c->detach('foo') does today
$c->detach('foo'): would do just like $c->dispatch('foo') but would
also change the action

I think this way the verbs would be best representing what they actually do.

Of course, this might break stuff and make all hell break loose and is
very similar to a previously mentioned alternative which people didn't
seem to like that much. But I, at least, think this would be the best
way to go if we don't want to end up being excessively verbose for
doing something that should be a simple task.

-Nilson Santos F. Jr.

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


sri at oook

Apr 13, 2006, 9:11 PM

Post #22 of 29 (3048 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

14.04.2006 04:56 Nilson Santos Figueiredo Junior:
> I really think that the best solution would be something not backwards
> compatible if that's something reasonable (maybe provide
> backwards-compatibility through a plugin).

Thats no option.


--
sebastian


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


dom at idealx

Apr 14, 2006, 2:33 AM

Post #23 of 29 (3047 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sebastian Riedel a écrit :

> What about:
>
> $c->action('/foo/bar')->forward; $c->action('/foo/bar')->detach;

I like this style a lot, but I would also like to be able to specify
the action by the name of a sub as we currently do (because of URL
I18N issues). Named arguments perhaps?

$c->action(-url => '/foo/bar')->forward;
$c->action(-method => 'bar')->detach;

I also feel like others on the list that the "forward" word is
ambiguous, and "detach" feels like a bad choice here as well (by
naively reading the source I am under the impression that the
"/foo/bar" URI is going to be unavailable after it is "detached"). So
what about this then:

$c->action(-url => '/foo/bar')->call;
$c->action(-method => 'bar')->dispatch;


- --
Dominique QUATRAVAUX Ingénieur senior
01 44 42 00 08 IDEALX

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEP2xWMJAKAU3mjcsRAtkVAJ4xcFZznGe2HIcTFvzuM4RdS1o0pACgwgkE
zckFkJnlNq+1NxkWZFqO9vw=
=2zd5
-----END PGP SIGNATURE-----



_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


moseley at hank

Apr 14, 2006, 6:58 AM

Post #24 of 29 (3048 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On Fri, Apr 14, 2006 at 03:34:39AM +0200, Sebastian Riedel wrote:
> What about:
>
> $c->action('/foo/bar')->forward;
> $c->action('/foo/bar')->detach;
>
> or (suggested by mst):
>
>
> $c->forward( $c->action('/foo/bar') );
> $c->detach( $c->action('/foo/bar') );

That would work, and then in my App base I could define my own
method wrappers to name them what I like.

Still, seems like (from the volume of responses) that there would be
use for a new built-in method. Whatever it's called. Can't change
forward's behavior without breaking existing apps.

And one request is that if called *without* any arguments it defaults
to the default/list action.

$c->forward2;

I have controllers that commonly include a null Path attribute for a
"list" method. In my other actions I often want to "forward" to the
list action if input params are bad. So it's nice to not have to
name that action by name.


package App::C::Admin::User;

# show paged list of all users for /admin/user

sub list : Path {
my ( $self, $c ) = @_;

$c->paged_list( class => DB::User );
}

# edit for /admin/usrer/edit/3445

sub edit : Local {
my ( $self, $c, $id ) = @_;

# display list if bad $id passed in
return $c->forward2 unless $self->valid_id( $id );

...
}


My internal_redirect() that prompted this discussion on #catalyst
does this:

sub internal_redirect {
my ( $c, $action, @args ) = @_;

unless ( defined $action ) {
$action = $c->action->namespace;
} else {
$action = join '/', $c->action->namespace, $action
unless $action =~ m!^/!;
}

$c->res->body( $c->subreq( $action, @args ) );
return;
}



--
Bill Moseley
moseley [at] hank


_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst


acid06 at gmail

Apr 14, 2006, 6:59 AM

Post #25 of 29 (3029 views)
Permalink
Re: Another RFC. $c->call() [In reply to]

On 4/14/06, Sebastian Riedel <sri [at] oook> wrote:
> Thats no option.

Yes, I was serious. And I already knew this would be the sort of
response I'd get.
But that doesn't stop it from being what probably makes more sense, if
you were designing the whole API right now and didn't have this
backward compatibility constraint.

-Nilson Santos F. Jr.

_______________________________________________
Catalyst mailing list
Catalyst [at] lists
http://lists.rawmode.org/mailman/listinfo/catalyst

First page Previous page 1 2 Next page Last page  View All Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.