Ok, I think I'm close...

My main schema class:

package DB;

use base qw/DBIx::Class::Schema  DBIx::Class::AccessorGroup/;

__PACKAGE__->mk_group_accessors(simple => 'context');
__PACKAGE__->load_classes(qw//);
1;


My model class...

package WCN::Model::DB;

use strict;
use base qw/Catalyst::Model::DBIC::Schema::WCN/;

__PACKAGE__->config(
   schema_class => 'DB',
);

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

 $c->log->debug("  *** class: " . ref($self));

 my $new = bless({%$self}, ref $self);
 $new->schema(bless({%{$self->schema}}, ref($self->schema)));
 $new->schema->context($c);

 # Outputs 'WCN' which is correct
 $c->log->debug("  *** ref of context in self: ",
ref($new->schema->context()));

 return $new;
}

The debug prints the correct class of $c when ACCEPT_CONTEXT is
called, however $self->result_source->schema->context is not present
in the model objects.

Have I got the wrong end of the stick somewhere?

Many Thanks,

Scott.


On 2/27/07, Scott Thomson <[EMAIL PROTECTED]> wrote:
Hi,

This is exactly what I want to do, however I can't seem to get my head round
how to implement this solution, I've tried various incarnations but I don't
seem to be getting anywhere.

Annotations below, thanks for patience.

Scott


On 2/1/07, Juan Miguel Paredes <[EMAIL PROTECTED]> wrote:
> On 2/1/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> >
> > package MyApp::DataStore; # or whatever this is called
> >
> > use base qw/DBIx::Class::Schema/;
> >
> > __PACKAGE__->mk_group_accessors(simple => 'context');



I get this bit, (also add DBIx::Class::AccessorGroup to the base class list)

> > then
> >
> > my $new = bless ...
> >

> > $new->schema(bless(...)); # same trick on the schema
> >
> > $new->schema->context($c);

Is the above in the same file? what should replace the ellipsis

> > then in the DBIC code
> >
> > $self->result_source->schema->context;
> >
> > make more sense?
> >


Where exactly is the DBIC code? MyApp::Model::DataStore?


> Indeed, your suggestion worked fine, thanks a lot!  Just had to add
> DBIx::Class::AccessorGroup to the schema class
>
> Regards,
>
> Juan.
>
> _______________________________________________
> List: [email protected]
> Listinfo:
http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>



_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to