[Catalyst-dev] Moose + Catalyst port

Guillermo Roditi groditi at gmail.com
Sat Mar 15 01:33:32 GMT 2008


OK,

In case you were not aware, konobi is working on a Moosified Catalyst
branch. I just joined the effort today, but since I am not very
familiar with the cat internals I ran into some trouble. Most of my
issues had to do with the way Catalyst uses class data and MI.

Questions:
Anyone familiar with both Class::Data::Inheritable and MooseX::ClassAttribute ?
Catalyst uses class data in a couple of key spots and I'm not familiar
with either of the above modules other than what I've been learning
today, but after writing a short test, which is attached below, i
noticed they are not compatible.  Suggestions?

Here are some proposals, feel free to tell me how wrong I am, but
please tell me why:

* Implement Catalyst::AttrContainer as role.
Problem here stems from class data. How do we create class data in a role?
It was my original intention to use MooseX::ClassAttribute, but that
won't work. I'd like to see some suggestions here, if anyone has any.

* Catalyst::Controller
is the only subclass of AttrContainer. should we just move the code in
here? and avoid the mess above?

* Catalyst::Component
More Class::Data::Inheritable woes. See &config to see what I mean. I
don't understand the desired end result, so I don't know how to
recreate the behavior and test for it
COMPONENT calls $self->NEXT::COMPONENT. why? We have no superclasses.
I figure this is a MI thing. Are we sticking with NEXT for the Moose
port? I was thinking of moving to just using method modifiers. I have
no clue what to replace this call with. I could use some help here.
COMPONENT, in the case of not being able to build a new instance via
new just blesses the config + args. Uhm. do we need to keep compat for
this? The Moose port will always return an object on new because
Moose::Object will do that for us.

* Multiple Inheritance
It seems to me that by using roles we could totally eliminate this
from the codebase

* NEXT::* / SUPER::* / next::method / super()
Like I mentioned above.. what do we want? are we just using Moose
method modifiers or do we want to use NEXT or next or whatever

-- 
Guillermo Roditi (groditi)

####BEGIN ClassAttribute VS C::D::I tests
{
  package CDAFoo;
  use base qw(Class::Data::Inheritable);
  CDAFoo->mk_classdata('beep');
  CDAFoo->mk_classdata('bop');

  package CDABar;
  use base 'CDAFoo';
  CDABar->mk_classdata('beep');
}

{
  package MCAFoo;
  use Moose;
  use MooseX::ClassAttribute;
  class_has 'beep' => (is => 'rw');
  class_has 'bop'  => (is => 'rw');

  package MCABar;
  use Moose;
  use MooseX::ClassAttribute;
  extends 'MCAFoo';
  class_has 'beep' => (is => 'rw');
}

package main;

use strict;
use warnings;
use Test::More tests => 6;

CDAFoo->beep('FOO BEEP');
CDAFoo->bop('FOO BOP');
MCAFoo->beep('FOO BEEP');
MCAFoo->bop('FOO BOP');

is(CDAFoo->beep, MCAFoo->beep, 'FOO BEEP');
is(CDAFoo->bop,  MCAFoo->bop,  'FOO BOP');

CDABar->beep('BAR BEEP');
CDABar->bop('BAR BOP');
MCABar->beep('BAR BEEP');
MCABar->bop('BAR BOP');

is(CDABar->beep, MCABar->beep, 'FOO BEEP');
is(CDABar->bop,  MCABar->bop,  'BAR BOP');

is(CDAFoo->beep, MCAFoo->beep, 'FOO BEEP');
is(CDAFoo->bop,  MCAFoo->bop,  'BAR BOP');



More information about the Catalyst-dev mailing list