Mailing List Archive

Still Confused
I'm working with v5 at the moment, primarily because that's what the
mojomojo app I was pointed at seems to use [based on use of subs with
attributes].

I've managed to confuse myself again, I've done the following:

catalyst.pl Magic
cd Magic
./script/create.pl controller Trick

I've tweaked lib/Magic.pm to:

sub default : Private {
my ( $self, $c ) = @_;
$c->forward( '/trick' );
}

sub trick : Private {
my ( $self, $c ) = @_;
$c->res->output(__PACKAGE__ . ' : trick');
}

Then I tried:

./script/test.pl
[snippage]
.=-----------------------
| Action
|=-----------------------
| -> /trick
| /default
'=-----------------------

Magic : trick


followed by

./script/test.pl /trick
[snippage]
.=-----------------------
| Action
|=-----------------------
| /trick/default
'=-----------------------

Congratulations, Magic::C::Trick is on Catalyst!


This is where my fundamental misunderstanding of everything starts to
become apparent ...

What should I do to be forwarded to Magic::C::Trick when I visit, well
anything that's not a /trick URI already.

I would have expected forward('trick') to use the lib/Magic.pm->trick()
function, and forward('/trick') to be treated the same way as
./script/test.pl /trick


I've tried to work this out, but for some reason I just can't get the
right incantations through my keyboard at the moment.

Chisel
--
Chisel Wright
e: chisel@herlpacker.co.uk
w: http://www.herlpacker.co.uk/

"This is not the greatest sig in the world, no, this is just a tribute."
Still Confused [ In reply to ]
Am 08.04.2005 um 21:59 schrieb Chisel Wright:

> I'm working with v5 at the moment, primarily because that's what the
> mojomojo app I was pointed at seems to use [based on use of subs with
> attributes].
>
> I've managed to confuse myself again, I've done the following:
>
> catalyst.pl Magic
> cd Magic
> ./script/create.pl controller Trick
>
> I've tweaked lib/Magic.pm to:
>
> sub default : Private {
> my ( $self, $c ) = @_;
> $c->forward( '/trick' );
> }
>
> sub trick : Private {
> my ( $self, $c ) = @_;
> $c->res->output(__PACKAGE__ . ' : trick');
> }
>
> Then I tried:
>
> ./script/test.pl
> [snippage]
> .=-----------------------
> | Action
> |=-----------------------
> | -> /trick
> | /default
> '=-----------------------
>
> Magic : trick
>
>
> followed by
>
> ./script/test.pl /trick
> [snippage]
> .=-----------------------
> | Action
> |=-----------------------
> | /trick/default
> '=-----------------------
>
> Congratulations, Magic::C::Trick is on Catalyst!
>
>
> This is where my fundamental misunderstanding of everything starts to
> become apparent ...
>
> What should I do to be forwarded to Magic::C::Trick when I visit, well
> anything that's not a /trick URI already.
>
> I would have expected forward('trick') to use the lib/Magic.pm->trick()
> function, and forward('/trick') to be treated the same way as
> ./script/test.pl /trick
>
>
> I've tried to work this out, but for some reason I just can't get the
> right incantations through my keyboard at the moment.

It works perfectly right! :)

You defined "sub trick : Private" which means that it's only
available for forwarding!
Try "sub trick : Local" or "sub trick : Global". ;)

--
sebastian
Still Confused [ In reply to ]
On Fri, Apr 08, 2005 at 10:33:33PM +0200, Sebastian Riedel wrote:
> It works perfectly right! :)
>
> You defined "sub trick : Private" which means that it's only
> available for forwarding!
> Try "sub trick : Local" or "sub trick : Global". ;)

Hrm, maybe I'm communicating badly (again), given:

package Magic;

use strict;
use Catalyst qw/-Debug/;

our $VERSION = '0.01';

Magic->config(
name => 'Magic',
root => '/home/chisel/development/web/catalyst/Magic/root',
);

Magic->setup;

sub default : Private {
my ( $self, $c ) = @_;
#$c->res->output('Congratulations, Magic is on Catalyst!');
$c->forward('/trick');
}


package Magic::C::Trick;

use strict;
use base 'Catalyst::Base';

sub default : Private {
my ( $self, $c ) = @_;
$c->res->output('Congratulations, Magic::C::Trick is on Catalyst!');
}


I was expecting

./script/test.pl /

to produce

Congratulations, Magic::C::Trick is on Catalyst!


I'm going to go away and re-reread Catalyst::Manual::Intro to see what
I've missed/misunderstood.

Chisel
--
Chisel Wright
e: chisel@herlpacker.co.uk
w: http://www.herlpacker.co.uk/

"This is not the greatest sig in the world, no, this is just a tribute."
Still Confused [ In reply to ]
Am 08.04.2005 um 23:04 schrieb Chisel Wright:

> On Fri, Apr 08, 2005 at 10:33:33PM +0200, Sebastian Riedel wrote:
>> It works perfectly right! :)
>>
>> You defined "sub trick : Private" which means that it's only
>> available for forwarding!
>> Try "sub trick : Local" or "sub trick : Global". ;)
>
> Hrm, maybe I'm communicating badly (again), given:
>
> package Magic;
>
> use strict;
> use Catalyst qw/-Debug/;
>
> our $VERSION = '0.01';
>
> Magic->config(
> name => 'Magic',
> root => '/home/chisel/development/web/catalyst/Magic/root',
> );
>
> Magic->setup;
>
> sub default : Private {
> my ( $self, $c ) = @_;
> #$c->res->output('Congratulations, Magic is on Catalyst!');
> $c->forward('/trick');
> }
>
>
> package Magic::C::Trick;
>
> use strict;
> use base 'Catalyst::Base';
>
> sub default : Private {
> my ( $self, $c ) = @_;
> $c->res->output('Congratulations, Magic::C::Trick is on
> Catalyst!');
> }
>
>
> I was expecting
>
> ./script/test.pl /
>
> to produce
>
> Congratulations, Magic::C::Trick is on Catalyst!

Aaah, now i get it... :)

forward only accepts "internal" addressing, we now make a difference
between external and internal, default, begin, auto and end are only
evaluated for external ones.

--
sebastian
Still Confused [ In reply to ]
On Sat, Apr 09, 2005 at 12:12:07AM +0200, Sebastian Riedel wrote:
> Aaah, now i get it... :)
>
> forward only accepts "internal" addressing, we now make a difference
> between external and internal, default, begin, auto and end are only
> evaluated for external ones.

Aha, it's becoming clearer. I bit of tweaking and I realise that I can
actually do:

$c->forward('/trick/view');
[.if I have sub view : Local { } in Trick.pm]

so I'm not "locked in" to a particular controller, I just can't leap
from one default to another ... right?

After months of working with someone else's nasty homegrown webapp
framework, and hearing Maypole's praises from a cow-orker [.and also how
he wishes Catalyst had been out earlier, or his current project had
started about 6 months later], I know that Catalyst is a good way
forward .. I just need to get my head into the right mindset to work
with it.

I can see how easy it's going to be, once I get over the initial
learning curve for slotting bits together.

Cheers for your help and time so far ...

Chisel
--
Chisel Wright
e: chisel@herlpacker.co.uk
w: http://www.herlpacker.co.uk/

"This is not the greatest sig in the world, no, this is just a tribute."
Still Confused [ In reply to ]
Am 09.04.2005 um 00:25 schrieb Chisel Wright:

> On Sat, Apr 09, 2005 at 12:12:07AM +0200, Sebastian Riedel wrote:
>> Aaah, now i get it... :)
>>
>> forward only accepts "internal" addressing, we now make a difference
>> between external and internal, default, begin, auto and end are only
>> evaluated for external ones.
>
> Aha, it's becoming clearer. I bit of tweaking and I realise that I can
> actually do:
>
> $c->forward('/trick/view');
> [.if I have sub view : Local { } in Trick.pm]
>
> so I'm not "locked in" to a particular controller, I just can't leap
> from one default to another ... right?

Exactly.
You see the "private" action map when starting with -Debug enabled.

>
> After months of working with someone else's nasty homegrown webapp
> framework, and hearing Maypole's praises from a cow-orker [.and also how
> he wishes Catalyst had been out earlier, or his current project had
> started about 6 months later], I know that Catalyst is a good way
> forward .. I just need to get my head into the right mindset to work
> with it.

Well, Cat5 is a very fresh collaborative design by some crazy weirdos,
so we are all still in the learning phase. ;)

--
sebastian