[Catalyst] Question about Angerwhale Catalyst Application

John Napiorkowski jjn1056 at yahoo.com
Fri Feb 9 16:32:48 GMT 2007


Hi,

I guess this question might be a little OT for the
list, but I figured what I was wondering about could
be of interest to people other than myself.

I've been looking at the source code of Angerwhale
(http://search.cpan.org/~jrockway/Angerwhale-0.02/)
because I'm always interested in learning about the
ways other people build Catalyst applications.  One
thing I was trying to understand was the reference to
the context object in the new method of one of the
models
(http://search.cpan.org/~jrockway/Angerwhale-0.02/lib/Angerwhale/Model/Filesystem.pm)

Here's a few lines of the code to illustrate:

sub new {
    my ($self, $c) = @_;
    $self = $self->NEXT::new(@_);
    
    $self->context($c);
....
}

I was under the impression that it you needed the
context in a component you needed to override
ACCEPT_CONTEXT, since new is only called once when the
application starts up.  Using ACCEPT_CONTEXT
transforms your component to a type Class, since it
creates a new object for each request instead of using
the same one over and over.  But maybe I am not
understanding it?

Also, what's the benefit of override new instead of
COMPONENT?  Was there any particular thinking that
went into this choice?

Appreciate some thoughts, just trying to improve my
best practices.

Thanks,
John


 
____________________________________________________________________________________
We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 



More information about the Catalyst mailing list