[Catalyst-dev] Moose + Catalyst port
Jonathan Rockway
jon at jrock.us
Sat Mar 15 20:40:53 GMT 2008
* On Fri, Mar 14 2008, Dave Rolsky wrote:
> One thing you'll need to do is look for uses of this sort of stuff in
> plugins, which is what COMPONENT is used for, AFAICT. Same goes for
> ACCEPT_CONTEXT.
COMPONENT is for instantiating a Component at Catalyst startup time.
ACCEPT_CONTEXT is for instantiating a Component at request time. This
model doesn't need to change.
> I think the biggest thing to think about is plugins, since that's a
> major piece of how Catalyst works. It'd be nice if plugins could be
> defined in a way that didn't involve jamming a bazillion roles into
> the Catalyst namespace ;)
Most of the things that are plugins shouldn't be. Sessions and
Authentication will both be models. That leaves plugins for things
like:
package MyApp;
use Catalyst qw(DebugRequest); # this is now one of those clever
# Moose->import_to things
package Catalyst::Plugin::DebugRequest;
before 'prepare_action' => sub {
my ($c) = @_;
$c->log->debug( 'About to handle '. $c->req->uri );
}
This doesn't really clutter the namespace because it's just modifying
things. I suppose plugins can add methods, but let's not document that
and see what happens.
It should be possible to apply Plugins to the other classes:
* config (let's make this a class; a plugin can then load config
files, etc.)
* request
* response
* logger (maybe standardize on MX::LogDispatch)
* application (that's the above thing)
* context
* stash (?) # the idea here is to impose some structure on $c->stash
# on a per-request basis
This is easy enough to implement:
package Catalyst;
has logger => (
is => 'ro',
isa => 'Catalyst::Log',
default => sub {
Moose::Meta::Class->create_anon_instance(
superclasses => ['Catalyst::Log'],
roles => [$self->_logger_roles],
};
);
As for sessions, let's use Data::Session for Catalyst::Model::Session.
Code is currently at http://git.jrock.us/?p=Data-Session.git;a=summary
Regards,
Jonathan Rockway
--
print just => another => perl => hacker => if $,=$"
More information about the Catalyst-dev
mailing list