[Catalyst] multiple schemas based on login

James R. Leu jleu at mindspring.com
Thu Jun 7 13:56:53 GMT 2007

I do something very similar.  Here is the piece of code you need to
get you going (I originally got my example from the list back in Feb or Mar):

package MyApp::Model::FooDB;

use base 'Catalyst::Model::DBIC::Schema';

    my $self = shift;
    my $c = shift;

    my $schema = $self->schema();
    my @sources = $schema->sources();
    my $source;
    foreach $source (@sources) {
        my $name = $schema->source($source)->name();
	# name is 'table' from your DBIx::Class
	# change it, and then store it away

This code was heavily modified from my actual use, so there might be something
that is not quite right, but it should get you going in the right direction.
The key is implementing you own ACCEPT_CONTEXT method and changing aspects
of the Model before the database connection is created.

On Wed, Jun 06, 2007 at 04:03:44PM -0500, Jonny Appleseed wrote:
> Hello,
> I am using catalyst with DBIC::Schema and need to connect to a
> different database -- with the same schema definitions -- based on
> which user is logged in to the App.  Each of our clients data is
> stored in separate mysql databases.
> I have spent the whole day looking for examples of somebody doing this
> and thought I came closer when I stumbled upon the documentation for
> storage::dbi an accept_context but have not been able to come up with
> a solution.
> Could somebody please point me to solid documentation or to an example
> of somebody pulling this off?
> Sincerely, Guy Debord
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/

James R. Leu
jleu at mindspring.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070607/07e92232/attachment.pgp

More information about the Catalyst mailing list