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

Mailing List Archive: Catalyst: Users

Catalyst 5 Preview, Part 2

 

 

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


sriatoook.de

Apr 4, 2005, 11:15 PM

Post #1 of 5 (961 views)
Permalink
Catalyst 5 Preview, Part 2

We've been busy today fixing inheritance, and we've finally chosen a
solution quite similar to Mason's autohandlers. :)


package MyApp;

sub begin : Private {}
sub auto : Private { return 1 }
sub end : Private {}

package MyApp::C::Foo;

sub auto : Private { return 1 }
sub bar : Local {}
sub end : Private {}

Now if you request http://localhost:3000/foo/bar/ Cat5 would process:

MyApp->begin;

MyApp->auto;
MyApp::C::Foo->auto;
MyApp::C::Foo->bar;

MyApp::C::Foo->end;


So we have two built in actions (begin/end) and a processing chain in
between.

auto is a new built in action which like Mason's autohandlers gets
called before the requested action (bar).
They also have the ability to break the chain by returning 0, which is
very useful for authentication and stuff.

begin and end are not chained, just overloadable.

Hope this wasn't too complicated, and you get an idea how things work.

Btw. default works equivalent to Mason dhandlers. ;)

--
sebastian


uwe.voelkeratgmx.de

Apr 5, 2005, 9:23 PM

Post #2 of 5 (896 views)
Permalink
Catalyst 5 Preview, Part 2 [In reply to]

Sorry, it's me again. :-)

I have a few questions:

> package MyApp;
>
> sub begin : Private {}
> sub auto : Private { return 1 }
> sub end : Private {}
>
> package MyApp::C::Foo;
>
> sub auto : Private { return 1 }
> sub bar : Local {}
> sub end : Private {}
>
> Now if you request http://localhost:3000/foo/bar/ Cat5 would process:
>
> MyApp->begin;
>
> MyApp->auto;
> MyApp::C::Foo->auto;
> MyApp::C::Foo->bar;
>
> MyApp::C::Foo->end;

1. Why is MyApp->end not processed?

2. What would happened if a sub MyApp::C::Foo->begin had existed?

3. What happens if in MyApp a sub with :Path('/foo/bar') exists? Which
one will be called? When both are called - in which order?


Thank you,

good bye,
Uwe


sriatoook.de

Apr 5, 2005, 10:16 PM

Post #3 of 5 (902 views)
Permalink
Catalyst 5 Preview, Part 2 [In reply to]

Am 05.04.2005 um 21:20 schrieb Uwe Voelker:

> Sorry, it's me again. :-)

:)

> I have a few questions:
>
>> package MyApp;
>> sub begin : Private {}
>> sub auto : Private { return 1 }
>> sub end : Private {}
>> package MyApp::C::Foo;
>> sub auto : Private { return 1 }
>> sub bar : Local {}
>> sub end : Private {}
>> Now if you request http://localhost:3000/foo/bar/ Cat5 would process:
>> MyApp->begin;
>> MyApp->auto;
>> MyApp::C::Foo->auto;
>> MyApp::C::Foo->bar;
>> MyApp::C::Foo->end;
>
> 1. Why is MyApp->end not processed?

Because MyApp::C::Foo->end overloads it

>
> 2. What would happened if a sub MyApp::C::Foo->begin had existed?

It would overload MyApp->begin

>
> 3. What happens if in MyApp a sub with :Path('/foo/bar') exists? Which
> one will be called? When both are called - in which order?

There can be only one, so the one defined last would get executed.


--
sebastian


alan.humphreyatcomcast.net

Apr 6, 2005, 11:16 AM

Post #4 of 5 (910 views)
Permalink
Catalyst 5 Preview, Part 2 [In reply to]

Is there a concept of SUPER here? In your example, how would I ensure
that MyApp->end gets called? Forwarding?

-----Original Message-----
From: catalyst-bounces [at] lists
[mailto:catalyst-bounces [at] lists] On Behalf Of Sebastian
Riedel
Sent: Monday, April 04, 2005 1:16 PM
To: catalyst [at] lists
Subject: [Catalyst] Catalyst 5 Preview, Part 2

We've been busy today fixing inheritance, and we've finally chosen a
solution quite similar to Mason's autohandlers. :)


package MyApp;

sub begin : Private {}
sub auto : Private { return 1 }
sub end : Private {}

package MyApp::C::Foo;

sub auto : Private { return 1 }
sub bar : Local {}
sub end : Private {}

Now if you request http://localhost:3000/foo/bar/ Cat5 would process:

MyApp->begin;

MyApp->auto;
MyApp::C::Foo->auto;
MyApp::C::Foo->bar;

MyApp::C::Foo->end;


So we have two built in actions (begin/end) and a processing chain in
between.

auto is a new built in action which like Mason's autohandlers gets
called before the requested action (bar).
They also have the ability to break the chain by returning 0, which is
very useful for authentication and stuff.

begin and end are not chained, just overloadable.

Hope this wasn't too complicated, and you get an idea how things work.

Btw. default works equivalent to Mason dhandlers. ;)

--
sebastian


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


sriatoook.de

Apr 6, 2005, 3:17 PM

Post #5 of 5 (911 views)
Permalink
Catalyst 5 Preview, Part 2 [In reply to]

Am 06.04.2005 um 11:16 schrieb Alan Humphrey:

> Is there a concept of SUPER here? In your example, how would I ensure
> that MyApp->end gets called? Forwarding?

Mhm, we added the concept of unique private actions, so you can do
$c->forward('/end');

--
sebastian

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.