On 10/30/06, Steven Mackenzie <[EMAIL PROTECTED]> wrote:

In my quest to avoid typing resultset(''), is there a reason why I can't
have source_name create accessors in the $shema object, eg,
  $schema->MyBest->search;


In my experimenting, I've been doing stuff like this in my CGI::Application base class:

sub cgiapp_prerun {
    my $self = shift;
    my $schema = MyDB::Main->connect( ... );
   
    $self->param( schema => $schema );
}

sub schema {
    my $self = shift;
    return $self->param( 'schema' );
}

sub user {
    my $self = shift;
    return $self->schema->resultset('User')
}


Then, in a subclass, I can say:

sub foo_runmode {
    my $self = shift;
    my $user = $self->user->search( id => "foo" );
}


I can even auto-generate the per-table accessors from the schema.

Of course, I have no idea if any of this is a good idea. Use at your own peril. :)


Mike
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to