Alan Humphrey wrote:
Hi –
In a system like this (or in any system using config files) what does
your connect statement look like? I’m imagining something like:
my $schema = MyApp::Schema->connect();
or
my $schema = MyApp::Schema->connect( $env_override );
where the logic in connect takes care of dealing with the config file
and does other safety checks (e.g. no access to production data from a
non-production machine).
The docs say to overload connection to change the behavior of connect.
Is that what people are doing?
Thanks again, this discussion is very helpful.
- Alan
Right, it boils down to a $schema->connect(@connectinfo) statement, per
the docs. What @connectinfo looks like by the time it gets to connect()
is determined by the config system, e.g. merging files and values, etc.
I haven't needed to alter the behavior of connect(ion), so no
overrides here.
Your example safety check is interesting... I've always handled that
kind of authZ at the client-server level via the DB's access and
privilege system. Your app could handle such an "access denied"
exception at a higher level than connect() in order to, say, display a
user-friendly message.
As an aside, and to further pick on the example (sorry), I would hope
that the DBA (which might be you) has configured your prod DB to accept
connections from a very limited set of clients. For a simple web stack,
that might be localhost and the prod application server(s).
Cheers,
--Trevor
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]