On Mon, Jan 2, 2012 at 6:42 PM, Tomas Doran <[email protected]> wrote:

>
>
> Why are you messing around with ACCEPT_CONTEXT to do this?
>
> Why not just use COMPONENT to return the service class once?
>

Oh, I'm glad you brought that up.

Couple of reasons.  Not shown in my sample code, but I'm setting an
attribute at construction time from another model instance.

That is,

sub ACCEPT_CONTEXT {
    my ( $self, $c, @args ) = @_;

    my $service = $self->service;

    unless ( $service ) {
        my $service_class = $self->service_class;
        Class::MOP::load_class( $service_class );

        $service = $service_class->new({
            *connection => $c->model( 'Some::Client' ),*
        });
        ...

Where Model::Foo does use Model::Adaptor.   Maybe I could  work with
setup_components to make sure the model instances are created in the
correct order (or user Bread::Board as discussed earlier).

I'm also using a few models that create a socket at instance time and are
not smart about forking.  (In some cases I wrap those in a separate class,
though.)



https://github.com/bobtfish/**CatalystX-JobServer/blob/**
> master/lib/CatalystX/**JobServer/Web/Plugin/**ModelsFromConfig.pm#L7<https://github.com/bobtfish/CatalystX-JobServer/blob/master/lib/CatalystX/JobServer/Web/Plugin/ModelsFromConfig.pm#L7>
>
> Which is code to do exactly what you want - i.e. setup any models there is
> config for, but which don't have an explicit class on-disk, and then go on
> to setup controllers for each model setup.
>

Sure does!  Thanks,


-- 
Bill Moseley
[email protected]
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to