[Catalyst-commits] r14011 - in Catalyst-Model-DBIC-Schema/tags: .
0.49 0.49/lib/Catalyst/Helper/Model/DBIC
0.49/lib/Catalyst/Model/DBIC
0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema 0.49/t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed May 11 06:06:03 GMT 2011
Author: caelum
Date: 2011-05-11 06:06:03 +0000 (Wed, 11 May 2011)
New Revision: 14011
Added:
Catalyst-Model-DBIC-Schema/tags/0.49/
Catalyst-Model-DBIC-Schema/tags/0.49/Changes
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm
Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t
Removed:
Catalyst-Model-DBIC-Schema/tags/0.49/Changes
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm
Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm
Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t
Log:
tag 0.49
Deleted: Catalyst-Model-DBIC-Schema/tags/0.49/Changes
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/Changes 2011-04-29 12:50:12 UTC (rev 14007)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/Changes 2011-05-11 06:06:03 UTC (rev 14011)
@@ -1,196 +0,0 @@
-Revision history for Perl extension Catalyst::Model::DBIC::Schema
-
-0.48 Thu Dec 9 21:08:33 UTC 2010
- - fix usage of Try::Tiny in helper
-
-0.47 Wed Dec 8 22:21:06 UTC 2010
- - fix loader version check
-
-0.46 Wed Dec 8 13:35:28 UTC 2010
- - make use_moose detection more robust
-
-0.45 Wed Dec 8 12:05:58 UTC 2010
- - fix bug where non-result files were picked up for Moose check
-
-0.44 Tue Dec 7 03:50:48 UTC 2010
- - do not upgrade non-Moose schemas to use_moose=1 (RT#60558)
- - added col_collision_map => 'column_%s' as default loader option
- (will take effect on release of loader 0.07003)
-
-0.43 Sun Jul 25 01:00:34 UTC 2010
- - add dep for MooseX::NonMoose for the use_moose=1 option
-
-0.42 Sat Jul 24 23:14:27 UTC 2010
- - add use_moose=1 to loader options by default for create=static
-
-0.41 Wed Apr 28 08:42:13 EDT 2010
- - allow configuring ResultSets using the SchemaProxy trait
-
-0.40 Wed Feb 3 23:12:16 EST 2010
- - fix Replicated trait deps
-
-0.39 Mon Feb 1 10:08:51 EST 2010
- - better 'on_connect_do' parsing in Helper
-
-0.38 Fri Jan 15 06:41:24 EST 2010
- - re-add the 'storage' proxy method
-
-0.37 Thu Jan 14 10:20:43 EST 2010
- - support single replicant hashref from config
-
-0.36 Thu Jan 14 09:21:10 EST 2010
- - upgrading a schema to use_namespaces=1 will also turn on
- components=InflateColumn::DateTime (the default.)
-
-0.35 Sun Dec 27 04:50:53 EST 2009
- - forgot to edit Changes on last upload
-
-0.34 Sun Dec 27 03:49:34 EST 2009
- - move schema proxying into SchemaProxy trait which is off by default
-
-0.33 Sat Dec 26 08:04:49 EST 2009
- - fix test failure in 05testapp.t when env var not set (RT#53101)
-
-0.32 Wed Dec 23 01:22:06 EST 2009
- - Move documentation on setting up authentication into its own section
- for clarity.
- - Other misc documentation enhancements to make the docs more clear
- about the important things to know.
- - Convert Authentication Plugin configuration example to new style.
- - Support Coderefs in loader options for helper
- (patch from Ozum Eldogan ozum at ozum.net)
-
-0.31 Sun Oct 18 18:50:00 BST 2009
- - update for copyright info
-
-0.30 Sun Oct 18 01:35:36 EDT 2009
- - change no sources error to a warning (with a way to turn it off)
- - write connect_info to Model without a create= option as well
-
-0.29 Mon Sep 7 15:31:29 EDT 2009
- - support for coderef connect_info's
-
-0.28 Thu Aug 27 08:14:05 EDT 2009
- - autobox issues in dep chain, bump CX::Component::Traits dep
- (caelum)
-
-0.27 Wed Aug 26 09:09:44 EDT 2009
- - remove autobox usage due to reports of strange errors (caelum)
- - make schema a delegate for model, config too (caelum)
-
-0.26 Wed Jul 29 16:16:09 PDT 2009
- - fix loading connect_info from schema-defined connection
- (bluefeet, RT 48084)
- - detect wrong case for "dbi:" DSN part in DBIC helper (caelum)
- - Fix missing dep on Catalyst::Helper that made tests fail
- (wintrmute, RT 47449)
-
-0.25 Fri Jun 19 08:35:38 PDT 2009
- - fix dep on Tie::IxHash that made tests fail
- - add more attributes to ::Replicated trait
- - fixed infinte loop in helper if SQLite connect_info has only
- a DSN (dandv, RT #47101)
-
-0.24 Tue Jun 16 06:18:58 PDT 2009
- - Add tests for issues with Class::C3 which are caused to
- applications which use new Catalyst but old DBIC, and have
- use Class::C3 in the MyApp class (t0m)
- - die on empty schema
- - create=dynamic deprecation warning
- - helper passes loader opts to dynamic schemas
- - conversion to Moose
- - cursor caching support (via
- Catalyst::TraitFor::Model::DBIC::Schema::Caching)
- - ::Storage::Replicated support (via ::Replicated trait)
- - switch to hashref connect_info for DBIC 8100
- - better helper option parsing, with support for more options
- - more tests
-
-0.23 Sun Mar 8 20:30:02 GMT 2009
- - Kill a couple of warnings (one due to MRO::Compat)
-
-0.22 Tue Mar 3 15:54:19 UTC 2009
- - Fix oddly formatted error message.
- - Doc patch to clarify generated classes
- - Switch to use_namespaces and InflateColumn::DateTime for create=static
- by default, with backcompat
- - Switch to MRO::Compat from NEXT
- - Add support for extra Schema::Loader options such as db_schema and
- components
-
-0.21 Fri Aug 22 00:26:05 UTC 2008
- - doc fix (RT #31848)
- - connection_info can be just the DSN instead of an arrayref
-
-0.20 Wed May 23, 2007
- - Fix for rt.cpan.org #22426
- - Switch to Module::Install
- - Assorted small pod and cleanliness fixes
- - Some requirements bumped to the latest maint
- releases of the same major feature release
-
-0.18 Tue Aug 8 04:34:42 UTC 2006
- - Version bump for public release, no functional change
-
-0.17_01 Thu Jul 27 01:06:13 UTC 2006
- - Updated for DBIC 0.07
-
-0.16 Thu Jul 6 13:28:45 UTC 2006
- - Bugfix for create=static and connect_info coderef snippets
- - Be more verbose when connection_info is not set.
-
-0.15 Tue Jun 6 01:33:57 UTC 2006
- - Fixed a serious bug in create=static usage
- - Re-arranged output generation so that the more likely
- failure to generate Schemas via create= will cause the
- helper to abort before generating the Model class itself
-
-0.14 Mon Jun 5 23:34:35 UTC 2006
- - Helpers merged, helper syntax changed
- - Everything updated for Schema::Loader 0.03001 support, including
- what amounts to using Loader in one-shot mode to generate
- a manual Schema with matching Model.
- - fixed stupid typo in docs
-
-0.13 Wed Apr 26 2006
- - noted support via mailing lists
-
-0.12 Tue Apr 25 2006
- - SYNOPSIS improved substantially to help newbies get started
-
-0.11 Sun Mar 26 17:22:31 UTC 2006
- - Removed on_connect_do config setting (it was only out
- in public for 4 days...).
- - Support for on_connect_do and sql_maker options as part
- of connect_info
-
-0.10 Wed Mar 22 07:06:02 UTC 2006
- - Added on_connect_do config setting
- - Added convenience method for ->schema->storage from paulm
-
-0.08 Tue Feb 28 00:04:16 UTC 2006
- - Bumped D::C::Schema::Loader recommendation to 0.02003
- (should have been done last release)
- - Removed the ->require stuff added in 0.07, it doesn't
- do what it is supposed to do. For now, users can layer
- at the Schema::Loader level rather than at Model.
-
-0.07 Sun Feb 19 21:50:18 UTC 2006
- - bugfix for ::SchemaLoader::Foo password argument, and
- switch to connect_info argument of new Schema::Loader
- - Added ->require for source classes, so that you can
- layer in lib/MyApp/Model/Foo/Bar.pm on top of the
- generated MyApp::Model::Foo::Bar.
-
-0.06 Sat Feb 18 19:05:17 UTC 2006
- - Fix simple pod-related bug introduced in last rev
- - Added optional test that uses the helpers
-
-0.05 Fri Feb 17 20:52:21 UTC 2006
- - Stop showing the template pod in pod tools and cpan,
- per Gavin's email.
- - Bump DBIx::Class pre-req to 0.05006, to prevent likely but
- subtle issues under mod_perl engines.
-
-0.04 Mon Feb 13 04:22:49 UTC 2006
- - First public release
Copied: Catalyst-Model-DBIC-Schema/tags/0.49/Changes (from rev 14010, Catalyst-Model-DBIC-Schema/trunk/Changes)
===================================================================
--- Catalyst-Model-DBIC-Schema/tags/0.49/Changes (rev 0)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/Changes 2011-05-11 06:06:03 UTC (rev 14011)
@@ -0,0 +1,202 @@
+Revision history for Perl extension Catalyst::Model::DBIC::Schema
+
+0.49 Wed May 11 06:03:50 UTC 2011
+ - make sure storage_type class is loaded before ->isa check in
+ Replicated trait (RT#65791)
+ - fix regex stringification test for perl 5.14 (RT#68098)
+ - update connect_info POD (RT#66010)
+
+0.48 Thu Dec 9 21:08:33 UTC 2010
+ - fix usage of Try::Tiny in helper
+
+0.47 Wed Dec 8 22:21:06 UTC 2010
+ - fix loader version check
+
+0.46 Wed Dec 8 13:35:28 UTC 2010
+ - make use_moose detection more robust
+
+0.45 Wed Dec 8 12:05:58 UTC 2010
+ - fix bug where non-result files were picked up for Moose check
+
+0.44 Tue Dec 7 03:50:48 UTC 2010
+ - do not upgrade non-Moose schemas to use_moose=1 (RT#60558)
+ - added col_collision_map => 'column_%s' as default loader option
+ (will take effect on release of loader 0.07003)
+
+0.43 Sun Jul 25 01:00:34 UTC 2010
+ - add dep for MooseX::NonMoose for the use_moose=1 option
+
+0.42 Sat Jul 24 23:14:27 UTC 2010
+ - add use_moose=1 to loader options by default for create=static
+
+0.41 Wed Apr 28 08:42:13 EDT 2010
+ - allow configuring ResultSets using the SchemaProxy trait
+
+0.40 Wed Feb 3 23:12:16 EST 2010
+ - fix Replicated trait deps
+
+0.39 Mon Feb 1 10:08:51 EST 2010
+ - better 'on_connect_do' parsing in Helper
+
+0.38 Fri Jan 15 06:41:24 EST 2010
+ - re-add the 'storage' proxy method
+
+0.37 Thu Jan 14 10:20:43 EST 2010
+ - support single replicant hashref from config
+
+0.36 Thu Jan 14 09:21:10 EST 2010
+ - upgrading a schema to use_namespaces=1 will also turn on
+ components=InflateColumn::DateTime (the default.)
+
+0.35 Sun Dec 27 04:50:53 EST 2009
+ - forgot to edit Changes on last upload
+
+0.34 Sun Dec 27 03:49:34 EST 2009
+ - move schema proxying into SchemaProxy trait which is off by default
+
+0.33 Sat Dec 26 08:04:49 EST 2009
+ - fix test failure in 05testapp.t when env var not set (RT#53101)
+
+0.32 Wed Dec 23 01:22:06 EST 2009
+ - Move documentation on setting up authentication into its own section
+ for clarity.
+ - Other misc documentation enhancements to make the docs more clear
+ about the important things to know.
+ - Convert Authentication Plugin configuration example to new style.
+ - Support Coderefs in loader options for helper
+ (patch from Ozum Eldogan ozum at ozum.net)
+
+0.31 Sun Oct 18 18:50:00 BST 2009
+ - update for copyright info
+
+0.30 Sun Oct 18 01:35:36 EDT 2009
+ - change no sources error to a warning (with a way to turn it off)
+ - write connect_info to Model without a create= option as well
+
+0.29 Mon Sep 7 15:31:29 EDT 2009
+ - support for coderef connect_info's
+
+0.28 Thu Aug 27 08:14:05 EDT 2009
+ - autobox issues in dep chain, bump CX::Component::Traits dep
+ (caelum)
+
+0.27 Wed Aug 26 09:09:44 EDT 2009
+ - remove autobox usage due to reports of strange errors (caelum)
+ - make schema a delegate for model, config too (caelum)
+
+0.26 Wed Jul 29 16:16:09 PDT 2009
+ - fix loading connect_info from schema-defined connection
+ (bluefeet, RT 48084)
+ - detect wrong case for "dbi:" DSN part in DBIC helper (caelum)
+ - Fix missing dep on Catalyst::Helper that made tests fail
+ (wintrmute, RT 47449)
+
+0.25 Fri Jun 19 08:35:38 PDT 2009
+ - fix dep on Tie::IxHash that made tests fail
+ - add more attributes to ::Replicated trait
+ - fixed infinte loop in helper if SQLite connect_info has only
+ a DSN (dandv, RT #47101)
+
+0.24 Tue Jun 16 06:18:58 PDT 2009
+ - Add tests for issues with Class::C3 which are caused to
+ applications which use new Catalyst but old DBIC, and have
+ use Class::C3 in the MyApp class (t0m)
+ - die on empty schema
+ - create=dynamic deprecation warning
+ - helper passes loader opts to dynamic schemas
+ - conversion to Moose
+ - cursor caching support (via
+ Catalyst::TraitFor::Model::DBIC::Schema::Caching)
+ - ::Storage::Replicated support (via ::Replicated trait)
+ - switch to hashref connect_info for DBIC 8100
+ - better helper option parsing, with support for more options
+ - more tests
+
+0.23 Sun Mar 8 20:30:02 GMT 2009
+ - Kill a couple of warnings (one due to MRO::Compat)
+
+0.22 Tue Mar 3 15:54:19 UTC 2009
+ - Fix oddly formatted error message.
+ - Doc patch to clarify generated classes
+ - Switch to use_namespaces and InflateColumn::DateTime for create=static
+ by default, with backcompat
+ - Switch to MRO::Compat from NEXT
+ - Add support for extra Schema::Loader options such as db_schema and
+ components
+
+0.21 Fri Aug 22 00:26:05 UTC 2008
+ - doc fix (RT #31848)
+ - connection_info can be just the DSN instead of an arrayref
+
+0.20 Wed May 23, 2007
+ - Fix for rt.cpan.org #22426
+ - Switch to Module::Install
+ - Assorted small pod and cleanliness fixes
+ - Some requirements bumped to the latest maint
+ releases of the same major feature release
+
+0.18 Tue Aug 8 04:34:42 UTC 2006
+ - Version bump for public release, no functional change
+
+0.17_01 Thu Jul 27 01:06:13 UTC 2006
+ - Updated for DBIC 0.07
+
+0.16 Thu Jul 6 13:28:45 UTC 2006
+ - Bugfix for create=static and connect_info coderef snippets
+ - Be more verbose when connection_info is not set.
+
+0.15 Tue Jun 6 01:33:57 UTC 2006
+ - Fixed a serious bug in create=static usage
+ - Re-arranged output generation so that the more likely
+ failure to generate Schemas via create= will cause the
+ helper to abort before generating the Model class itself
+
+0.14 Mon Jun 5 23:34:35 UTC 2006
+ - Helpers merged, helper syntax changed
+ - Everything updated for Schema::Loader 0.03001 support, including
+ what amounts to using Loader in one-shot mode to generate
+ a manual Schema with matching Model.
+ - fixed stupid typo in docs
+
+0.13 Wed Apr 26 2006
+ - noted support via mailing lists
+
+0.12 Tue Apr 25 2006
+ - SYNOPSIS improved substantially to help newbies get started
+
+0.11 Sun Mar 26 17:22:31 UTC 2006
+ - Removed on_connect_do config setting (it was only out
+ in public for 4 days...).
+ - Support for on_connect_do and sql_maker options as part
+ of connect_info
+
+0.10 Wed Mar 22 07:06:02 UTC 2006
+ - Added on_connect_do config setting
+ - Added convenience method for ->schema->storage from paulm
+
+0.08 Tue Feb 28 00:04:16 UTC 2006
+ - Bumped D::C::Schema::Loader recommendation to 0.02003
+ (should have been done last release)
+ - Removed the ->require stuff added in 0.07, it doesn't
+ do what it is supposed to do. For now, users can layer
+ at the Schema::Loader level rather than at Model.
+
+0.07 Sun Feb 19 21:50:18 UTC 2006
+ - bugfix for ::SchemaLoader::Foo password argument, and
+ switch to connect_info argument of new Schema::Loader
+ - Added ->require for source classes, so that you can
+ layer in lib/MyApp/Model/Foo/Bar.pm on top of the
+ generated MyApp::Model::Foo::Bar.
+
+0.06 Sat Feb 18 19:05:17 UTC 2006
+ - Fix simple pod-related bug introduced in last rev
+ - Added optional test that uses the helpers
+
+0.05 Fri Feb 17 20:52:21 UTC 2006
+ - Stop showing the template pod in pod tools and cpan,
+ per Gavin's email.
+ - Bump DBIx::Class pre-req to 0.05006, to prevent likely but
+ subtle issues under mod_perl engines.
+
+0.04 Mon Feb 13 04:22:49 UTC 2006
+ - First public release
Deleted: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2011-04-29 12:50:12 UTC (rev 14007)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -1,756 +0,0 @@
-package Catalyst::Helper::Model::DBIC::Schema;
-
-use namespace::autoclean;
-use Moose;
-no warnings 'uninitialized';
-
-our $VERSION = '0.48';
-$VERSION = eval $VERSION;
-
-use Carp;
-use Tie::IxHash ();
-use Data::Dumper ();
-use List::Util 'first';
-use MooseX::Types::Moose qw/Str HashRef Bool ArrayRef/;
-use Catalyst::Model::DBIC::Schema::Types 'CreateOption';
-use List::MoreUtils 'firstidx';
-use Scalar::Util 'looks_like_number';
-use File::Find 'finddepth';
-use Try::Tiny;
-use Cwd 'getcwd';
-
-=head1 NAME
-
-Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
-
-=head1 SYNOPSIS
-
- script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \
- [ create=dynamic | create=static ] [ traits=trait1,trait2... ] \
- [ Schema::Loader opts ] [ dsn user pass ] \
- [ other connect_info args ]
-
-=head1 DESCRIPTION
-
-Helper for the DBIC Schema Models.
-
-=head2 Arguments:
-
-C<CatalystModelName> is the short name for the Catalyst Model class
-being generated (i.e. callable with C<$c-E<gt>model('CatalystModelName')>).
-
-C<MyApp::SchemaClass> is the fully qualified classname of your Schema,
-which might or might not yet exist. Note that you should have a good
-reason to create this under a new global namespace, otherwise use an
-existing top level namespace for your schema class.
-
-C<create=dynamic> instructs this Helper to generate the named Schema
-class for you, basing it on L<DBIx::Class::Schema::Loader> (which
-means the table information will always be dynamically loaded at
-runtime from the database).
-
-C<create=static> instructs this Helper to generate the named Schema
-class for you, using L<DBIx::Class::Schema::Loader> in "one shot"
-mode to create a standard, manually-defined L<DBIx::Class::Schema>
-setup, based on what the Loader sees in your database at this moment.
-A Schema/Model pair generated this way will not require
-L<DBIx::Class::Schema::Loader> at runtime, and will not automatically
-adapt itself to changes in your database structure. You can edit
-the generated classes by hand to refine them.
-
-C<traits> is the list of traits to apply to the model, see
-L<Catalyst::Model::DBIC::Schema> for details.
-
-C<Schema::Loader opts> are described in L</TYPICAL EXAMPLES> below.
-
-C<connect_info> arguments are the same as what
-DBIx::Class::Schema::connect expects, and are storage_type-specific.
-For DBI-based storage, these arguments are the dsn, username,
-password, and connect options, respectively. These are optional for
-existing Schemas, but required if you use either of the C<create=>
-options.
-
-username and password can be omitted for C<SQLite> dsns.
-
-Use of either of the C<create=> options requires L<DBIx::Class::Schema::Loader>.
-
-=head1 TYPICAL EXAMPLES
-
-Use DBIx::Class::Schema::Loader to create a static DBIx::Class::Schema,
-and a Model which references it:
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass create=static dbi:mysql:foodb myuname mypass
-
-Same, with extra connect_info args
-user and pass can be omitted for sqlite, since they are always empty
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass create=static dbi:SQLite:foo.db \
- AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
- on_connect_do='["select 1", "select 2"]' quote_char='"'
-
-If using a 2 character quote_char:
-
- script/myapp_create.pl ... quote_char='[]'
-
-B<ON WINDOWS COMMAND LINES QUOTING RULES ARE DIFFERENT>
-
-In C<cmd.exe> the above example would be:
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass create=static dbi:SQLite:foo.db \
- AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
- on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\""
-
-Same, but with extra Schema::Loader args (separate multiple values by commas):
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass create=static db_schema=foodb components=Foo,Bar \
- exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \
- dbi:Pg:dbname=foodb myuname mypass
-
-Coderefs are also supported:
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass create=static \
- inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \
- moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \
- dbi:mysql:foodb myuname mypass
-
-See L<DBIx::Class::Schema::Loader::Base> for a list of options
-
-Create a dynamic DBIx::Class::Schema::Loader-based Schema,
-and a Model which references it (B<DEPRECATED>):
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass create=dynamic dbi:mysql:foodb myuname mypass
-
-Reference an existing Schema of any kind, and provide some connection information for ->config:
-
- script/myapp_create.pl model CatalystModelName DBIC::Schema \
- MyApp::SchemaClass dbi:mysql:foodb myuname mypass
-
-Same, but don't supply connect information yet (you'll need to do this
-in your app config, or [not recommended] in the schema itself).
-
- script/myapp_create.pl model ModelName DBIC::Schema My::SchemaClass
-
-=cut
-
-has helper => (is => 'ro', isa => 'Catalyst::Helper', required => 1);
-has create => (is => 'rw', isa => CreateOption);
-has args => (is => 'ro', isa => ArrayRef);
-has traits => (is => 'rw', isa => ArrayRef);
-has schema_class => (is => 'ro', isa => Str, required => 1);
-has loader_args => (is => 'rw', isa => HashRef);
-has connect_info => (is => 'rw', isa => HashRef);
-has old_schema => (is => 'rw', isa => Bool, lazy_build => 1);
-has is_moose_schema => (is => 'rw', isa => Bool, lazy_build => 1);
-has result_namespace => (is => 'rw', isa => Str, lazy_build => 1);
-has components => (is => 'rw', isa => ArrayRef);
-
-=head1 METHODS
-
-=head2 mk_compclass
-
-This is called by L<Catalyst::Helper> with the commandline args to generate the
-files.
-
-=cut
-
-sub mk_compclass {
- my ($package, $helper, $schema_class, @args) = @_;
-
- my $self = $package->new(
- helper => $helper,
- schema_class => $schema_class,
- args => \@args
- );
-
- $self->run;
-}
-
-sub BUILD {
- my $self = shift;
- my $helper = $self->helper;
- my @args = @{ $self->args || [] };
-
- $helper->{schema_class} = $self->schema_class;
-
- @args = $self->_cleanup_args(\@args);
-
- my ($traits_idx, $traits);
- if (($traits_idx = firstidx { ($traits) = /^traits=(\S*)\z/ } @args) != -1) {
- my @traits = split /,/ => $traits;
-
- $self->traits(\@traits);
-
- $helper->{traits} = '['
- .(join ',' => map { qq{'$_'} } @traits)
- .']';
-
- splice @args, $traits_idx, 1, ();
- }
-
- if ($args[0] && $args[0] =~ /^create=(\S*)\z/) {
- $self->create($1);
- shift @args;
-
- if (@args) {
- $self->_parse_loader_args(\@args);
-
- $helper->{loader_args} = $self->_build_helper_loader_args;
- }
- }
-
- my $dbi_dsn_part;
- if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) {
- die
-qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)}
- if $dbi_dsn_part ne 'dbi';
-
- $helper->{setup_connect_info} = 1;
-
- $helper->{connect_info} =
- $self->_build_helper_connect_info(\@args);
-
- $self->_parse_connect_info(\@args);
- }
-
- $helper->{generator} = ref $self;
- $helper->{generator_version} = $VERSION;
-}
-
-=head2 run
-
-Can be called on an instance to generate the files.
-
-=cut
-
-sub run {
- my $self = shift;
-
- if ($self->create eq 'dynamic') {
- $self->_print_dynamic_deprecation_warning;
- $self->_gen_dynamic_schema;
- } elsif ($self->create eq 'static') {
- $self->_gen_static_schema;
- }
-
- $self->_gen_model;
-}
-
-sub _parse_loader_args {
- my ($self, $args) = @_;
-
- my %loader_args = $self->_read_loader_args($args);
-
- while (my ($key, $val) = each %loader_args) {
- next if $key =~ /^(?:components|constraint|exclude)\z/;
-
- $loader_args{$key} = $self->_eval($val);
- die "syntax error for loader args key '$key' with value '$val': $@"
- if $@;
- }
-
- my @components = $self->_build_loader_components(
- delete $loader_args{components},
- $loader_args{use_namespaces},
- );
-
- $self->components(\@components);
-
- for my $re_opt (qw/constraint exclude/) {
- $loader_args{$re_opt} = qr/$loader_args{$re_opt}/
- if exists $loader_args{$re_opt};
- }
-
- tie my %result, 'Tie::IxHash';
-
- %result = (
- relationships => 1,
- use_moose => $self->is_moose_schema ? 1 : 0,
- col_collision_map => 'column_%s',
- (!$self->old_schema ? (
- use_namespaces => 1
- ) : ()),
- (@components ? (
- components => \@components
- ) : ()),
- (%loader_args ? %loader_args : ()),
- );
-
- $self->loader_args(\%result);
-
- wantarray ? %result : \%result;
-}
-
-sub _read_loader_args {
- my ($self, $args) = @_;
-
- my %loader_args;
-
- while (@$args && $args->[0] !~ /^dbi:/i) {
- my ($key, $val) = split /=/, shift(@$args), 2;
-
- if ($self->_is_struct($val)) {
- $loader_args{$key} = $val;
- } elsif ((my @vals = split /,/ => $val) > 1) {
- $loader_args{$key} = \@vals;
- } else {
- $loader_args{$key} = $val;
- }
- }
-
- wantarray ? %loader_args : \%loader_args;
-}
-
-sub _build_helper_loader_args {
- my $self = shift;
-
- my $args = $self->loader_args;
-
- tie my %loader_args, 'Tie::IxHash';
-
- while (my ($arg, $val) = each %$args) {
- if (ref $val) {
- $loader_args{$arg} = $self->_data_struct_to_string($val);
- } else {
- $loader_args{$arg} = qq{'$val'};
- }
- }
-
- \%loader_args
-}
-
-sub _build_loader_components {
- my ($self, $components, $use_namespaces) = @_;
-
- my @components = $self->old_schema && (not $use_namespaces) ? ()
- : ('InflateColumn::DateTime');
-
- if ($components) {
- $components = [ $components ] if !ref $components;
- push @components, @$components;
- }
-
- wantarray ? @components : \@components;
-}
-
-sub _build_helper_connect_info {
- my ($self, $connect_info) = @_;
-
- my @connect_info = @$connect_info;
-
- my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info);
-
- tie my %helper_connect_info, 'Tie::IxHash';
-
- %helper_connect_info = (
- dsn => qq{'$dsn'},
- user => qq{'$user'},
- password => qq{'$password'}
- );
-
- for (@connect_info) {
- if (/^\s*{.*}\s*\z/) {
- my $hash = $self->_eval($_);
- die "Syntax errorr in connect_info hash: $_: $@" if $@;
- my %hash = %$hash;
-
- for my $key (keys %hash) {
- my $val = $hash{$key};
-
- if (ref $val) {
- $val = $self->_data_struct_to_string($val);
- } else {
- $val = $self->_quote($val);
- }
-
- $helper_connect_info{$key} = $val;
- }
-
- next;
- }
-
- my ($key, $val) = split /=/, $_, 2;
-
- if ($key eq 'quote_char') {
- $helper_connect_info{$key} = length($val) == 1 ?
- $self->_quote($val) :
- $self->_data_struct_to_string([split //, $val]);
- } else {
- $helper_connect_info{$key} = $self->_quote_unless_struct($val);
- }
- }
-
- \%helper_connect_info
-}
-
-sub _build_old_schema {
- my $self = shift;
-
- return $self->result_namespace eq '' ? 1 : 0;
-}
-
-sub _build_is_moose_schema {
- my $self = shift;
-
- my @schema_parts = split '::', $self->schema_class;
-
- my $result_dir = File::Spec->catfile(
- $self->helper->{base}, 'lib', @schema_parts, $self->result_namespace
- );
-
- # assume yes for new schemas
- return 1 if not -d $result_dir;
-
- my $uses_moose = 1;
-
- my $cwd = getcwd;
-
- try {
- finddepth(sub {
- return if $File::Find::name !~ /\.pm\z/;
-
- open my $fh, '<', $File::Find::name
- or die "Could not open $File::Find::name: $!";
-
- my $code = do { local $/; <$fh> };
- close $fh;
-
- $uses_moose = 0 if $code !~ /\nuse Moose;\n/;
-
- die;
- }, $result_dir);
- };
-
- chdir $cwd;
-
- return $uses_moose;
-}
-
-sub _build_result_namespace {
- my $self = shift;
-
- my @schema_parts = split '::', $self->schema_class;
- my $schema_pm =
- File::Spec->catfile($self->helper->{base}, 'lib', @schema_parts) . '.pm';
-
- if (not -f $schema_pm) {
- eval { Class::MOP::load_class('DBIx::Class::Schema::Loader') };
-
- return 'Result' if $@;
-
- return (try { DBIx::Class::Schema::Loader->VERSION('0.05') }) ? 'Result' : '';
- }
-
- open my $fh, '<', $schema_pm or die "Could not open $schema_pm: $!";
- my $code = do { local $/; <$fh> };
- close $fh;
-
- my ($result_namespace) = $code =~ /result_namespace => '([^']+)'/;
-
- return $result_namespace if $result_namespace;
-
- return '' if $code =~ /->load_classes/;
-
- return 'Result';
-}
-
-sub _data_struct_to_string {
- my ($self, $data) = @_;
-
- local $Data::Dumper::Terse = 1;
- local $Data::Dumper::Quotekeys = 0;
- local $Data::Dumper::Indent = 0;
- local $Data::Dumper::Useqq = 1;
-
- return Data::Dumper->Dump([$data]);
-}
-
-sub _get_dsn_user_pass {
- my ($self, $connect_info) = @_;
-
- my $dsn = shift @$connect_info;
- my ($user, $password);
-
- if ($dsn =~ /sqlite/i) {
- ($user, $password) = ('', '');
- shift @$connect_info while @$connect_info and $connect_info->[0] eq '';
- } else {
- ($user, $password) = splice @$connect_info, 0, 2;
- }
-
- ($dsn, $user, $password)
-}
-
-sub _parse_connect_info {
- my ($self, $connect_info) = @_;
-
- my @connect_info = @$connect_info;
-
- my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info);
-
- tie my %connect_info, 'Tie::IxHash';
- @connect_info{qw/dsn user password/} = ($dsn, $user, $password);
-
- for (@connect_info) {
- if (/^\s*{.*}\s*\z/) {
- my $hash = $self->_eval($_);
- die "Syntax errorr in connect_info hash: $_: $@" if $@;
-
- %connect_info = (%connect_info, %$hash);
-
- next;
- }
-
- my ($key, $val) = split /=/, $_, 2;
-
- if ($key eq 'quote_char') {
- $connect_info{$key} = length($val) == 1 ? $val : [split //, $val];
- } elsif ($key =~ /^(?:name_sep|limit_dialect)\z/) {
- $connect_info{$key} = $val;
- } else {
- $connect_info{$key} = $self->_eval($val);
- }
-
- die "syntax error for connect_info key '$key' with value '$val': $@"
- if $@;
- }
-
- $self->connect_info(\%connect_info);
-
- \%connect_info
-}
-
-sub _is_struct {
- my ($self, $val) = @_;
-
- return $val =~ /^\s*(?:sub|[[{])/;
-}
-
-sub _quote {
- my ($self, $val) = @_;
-
- return 'q{'.$val.'}';
-}
-
-sub _quote_unless_struct {
- my ($self, $val) = @_;
-
- $val = $self->_quote($val) if not $self->_is_struct($val);
-
- return $val;
-}
-
-sub _eval {
- my ($self, $code) = @_;
-
- return $code if looks_like_number $code;
-
- return $code if not $self->_is_struct($code);
-
- return eval "{no strict; $code}";
-}
-
-sub _gen_dynamic_schema {
- my $self = shift;
-
- my $helper = $self->helper;
-
- my @schema_parts = split(/\:\:/, $self->schema_class);
- my $schema_file_part = pop @schema_parts;
-
- my $schema_dir = File::Spec->catfile(
- $helper->{base}, 'lib', @schema_parts
- );
- my $schema_file = File::Spec->catfile(
- $schema_dir, $schema_file_part . '.pm'
- );
-
- $helper->mk_dir($schema_dir);
- $helper->render_file('schemaclass', $schema_file);
-}
-
-sub _gen_static_schema {
- my $self = shift;
-
- die "cannot load schema without connect info" unless $self->connect_info;
-
- my $helper = $self->helper;
-
- my $schema_dir = File::Spec->catfile($helper->{base}, 'lib');
-
- try {
- Class::MOP::load_class('DBIx::Class::Schema::Loader')
- }
- catch {
- die "Cannot load DBIx::Class::Schema::Loader: $_";
- };
-
- DBIx::Class::Schema::Loader->import(
- "dump_to_dir:$schema_dir", 'make_schema_at'
- );
-
- make_schema_at(
- $self->schema_class,
- $self->loader_args,
- [$self->connect_info]
- );
-}
-
-sub _gen_model {
- my $self = shift;
- my $helper = $self->helper;
-
- $helper->render_file('compclass', $helper->{file} );
-}
-
-sub _print_dynamic_deprecation_warning {
- warn <<EOF;
-************************************ WARNING **********************************
-* create=dynamic is DEPRECATED, please use create=static instead. *
-*******************************************************************************
-EOF
- print "Continue? [y/n]: ";
- chomp(my $response = <STDIN>);
- exit 0 if $response =~ /^n(o)?\z/;
-}
-
-sub _cleanup_args {
- my ($self, $args) = @_;
-
-# remove blanks, ie. someoned doing foo \ bar
- my @res = grep !/^\s+\z/, @$args;
-
-# remove leading whitespace, ie. foo \ bar
- s/^\s*// for @res;
-
- @res
-}
-
-=head1 SEE ALSO
-
-General Catalyst Stuff:
-
-L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
-L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
-
-Stuff related to DBIC and this Model style:
-
-L<DBIx::Class>, L<DBIx::Class::Schema>,
-L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>
-
-=head1 AUTHOR
-
-See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
-L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
-
-=head1 COPYRIGHT
-
-See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
-
-__DATA__
-
-=begin pod_to_ignore
-
-__schemaclass__
-package [% schema_class %];
-
-use strict;
-use base qw/DBIx::Class::Schema::Loader/;
-
-__PACKAGE__->loader_options(
- [%- FOREACH key = loader_args.keys %]
- [% key %] => [% loader_args.${key} %],
- [%- END -%]
-
-);
-
-=head1 NAME
-
-[% schema_class %] - L<DBIx::Class::Schema::Loader> class
-
-=head1 SYNOPSIS
-
-See L<[% app %]>
-
-=head1 DESCRIPTION
-
-Dynamic L<DBIx::Class::Schema::Loader> schema for use in L<[% class %]>
-
-=head1 GENERATED BY
-
-[% generator %] - [% generator_version %]
-
-=head1 AUTHOR
-
-[% author.replace(',+$', '') %]
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
-
-__compclass__
-package [% class %];
-
-use strict;
-use base 'Catalyst::Model::DBIC::Schema';
-
-__PACKAGE__->config(
- schema_class => '[% schema_class %]',
- [% IF traits %]traits => [% traits %],[% END %]
- [% IF setup_connect_info %]connect_info => {
- [%- FOREACH key = connect_info.keys %]
- [% key %] => [% connect_info.${key} %],
- [%- END -%]
-
- }[% END %]
-);
-
-=head1 NAME
-
-[% class %] - Catalyst DBIC Schema Model
-
-=head1 SYNOPSIS
-
-See L<[% app %]>
-
-=head1 DESCRIPTION
-
-L<Catalyst::Model::DBIC::Schema> Model using schema L<[% schema_class %]>
-
-=head1 GENERATED BY
-
-[% generator %] - [% generator_version %]
-
-=head1 AUTHOR
-
-[% author.replace(',+$', '') %]
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
-__END__
-# vim:sts=4 sw=4:
Copied: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm (from rev 14010, Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Helper/Model/DBIC/Schema.pm)
===================================================================
--- Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm (rev 0)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -0,0 +1,752 @@
+package Catalyst::Helper::Model::DBIC::Schema;
+
+use namespace::autoclean;
+use Moose;
+no warnings 'uninitialized';
+
+our $VERSION = '0.49';
+$VERSION = eval $VERSION;
+
+use Carp;
+use Tie::IxHash ();
+use Data::Dumper ();
+use List::Util 'first';
+use MooseX::Types::Moose qw/Str HashRef Bool ArrayRef/;
+use Catalyst::Model::DBIC::Schema::Types 'CreateOption';
+use List::MoreUtils 'firstidx';
+use Scalar::Util 'looks_like_number';
+use File::Find 'finddepth';
+use Try::Tiny;
+use Cwd 'getcwd';
+
+=head1 NAME
+
+Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
+
+=head1 SYNOPSIS
+
+ script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \
+ [ create=dynamic | create=static ] [ traits=trait1,trait2... ] \
+ [ Schema::Loader opts ] [ dsn user pass ] \
+ [ other connect_info args ]
+
+=head1 DESCRIPTION
+
+Helper for the DBIC Schema Models.
+
+=head2 Arguments:
+
+C<CatalystModelName> is the short name for the Catalyst Model class
+being generated (i.e. callable with C<$c-E<gt>model('CatalystModelName')>).
+
+C<MyApp::SchemaClass> is the fully qualified classname of your Schema,
+which might or might not yet exist. Note that you should have a good
+reason to create this under a new global namespace, otherwise use an
+existing top level namespace for your schema class.
+
+C<create=dynamic> instructs this Helper to generate the named Schema
+class for you, basing it on L<DBIx::Class::Schema::Loader> (which
+means the table information will always be dynamically loaded at
+runtime from the database).
+
+C<create=static> instructs this Helper to generate the named Schema
+class for you, using L<DBIx::Class::Schema::Loader> in "one shot"
+mode to create a standard, manually-defined L<DBIx::Class::Schema>
+setup, based on what the Loader sees in your database at this moment.
+A Schema/Model pair generated this way will not require
+L<DBIx::Class::Schema::Loader> at runtime, and will not automatically
+adapt itself to changes in your database structure. You can edit
+the generated classes by hand to refine them.
+
+C<traits> is the list of traits to apply to the model, see
+L<Catalyst::Model::DBIC::Schema> for details.
+
+C<Schema::Loader opts> are described in L</TYPICAL EXAMPLES> below.
+
+C<connect_info> arguments are the same as what
+DBIx::Class::Schema::connect expects, and are storage_type-specific.
+For DBI-based storage, these arguments are the dsn, username,
+password, and connect options, respectively. These are optional for
+existing Schemas, but required if you use either of the C<create=>
+options.
+
+username and password can be omitted for C<SQLite> dsns.
+
+Use of either of the C<create=> options requires L<DBIx::Class::Schema::Loader>.
+
+=head1 TYPICAL EXAMPLES
+
+Use DBIx::Class::Schema::Loader to create a static DBIx::Class::Schema,
+and a Model which references it:
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass create=static dbi:mysql:foodb myuname mypass
+
+Same, with extra connect_info args
+user and pass can be omitted for sqlite, since they are always empty
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass create=static dbi:SQLite:foo.db \
+ AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
+ on_connect_do='["select 1", "select 2"]' quote_names=1
+
+B<ON WINDOWS COMMAND LINES QUOTING RULES ARE DIFFERENT>
+
+In C<cmd.exe> the above example would be:
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass create=static dbi:SQLite:foo.db \
+ AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \
+ on_connect_do="[\"select 1\", \"select 2\"]" quote_names=1
+
+Same, but with extra Schema::Loader args (separate multiple values by commas):
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass create=static db_schema=foodb components=Foo,Bar \
+ exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \
+ dbi:Pg:dbname=foodb myuname mypass
+
+Coderefs are also supported:
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass create=static \
+ inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \
+ moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \
+ dbi:mysql:foodb myuname mypass
+
+See L<DBIx::Class::Schema::Loader::Base> for a list of options
+
+Create a dynamic DBIx::Class::Schema::Loader-based Schema,
+and a Model which references it (B<DEPRECATED>):
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass create=dynamic dbi:mysql:foodb myuname mypass
+
+Reference an existing Schema of any kind, and provide some connection information for ->config:
+
+ script/myapp_create.pl model CatalystModelName DBIC::Schema \
+ MyApp::SchemaClass dbi:mysql:foodb myuname mypass
+
+Same, but don't supply connect information yet (you'll need to do this
+in your app config, or [not recommended] in the schema itself).
+
+ script/myapp_create.pl model ModelName DBIC::Schema My::SchemaClass
+
+=cut
+
+has helper => (is => 'ro', isa => 'Catalyst::Helper', required => 1);
+has create => (is => 'rw', isa => CreateOption);
+has args => (is => 'ro', isa => ArrayRef);
+has traits => (is => 'rw', isa => ArrayRef);
+has schema_class => (is => 'ro', isa => Str, required => 1);
+has loader_args => (is => 'rw', isa => HashRef);
+has connect_info => (is => 'rw', isa => HashRef);
+has old_schema => (is => 'rw', isa => Bool, lazy_build => 1);
+has is_moose_schema => (is => 'rw', isa => Bool, lazy_build => 1);
+has result_namespace => (is => 'rw', isa => Str, lazy_build => 1);
+has components => (is => 'rw', isa => ArrayRef);
+
+=head1 METHODS
+
+=head2 mk_compclass
+
+This is called by L<Catalyst::Helper> with the commandline args to generate the
+files.
+
+=cut
+
+sub mk_compclass {
+ my ($package, $helper, $schema_class, @args) = @_;
+
+ my $self = $package->new(
+ helper => $helper,
+ schema_class => $schema_class,
+ args => \@args
+ );
+
+ $self->run;
+}
+
+sub BUILD {
+ my $self = shift;
+ my $helper = $self->helper;
+ my @args = @{ $self->args || [] };
+
+ $helper->{schema_class} = $self->schema_class;
+
+ @args = $self->_cleanup_args(\@args);
+
+ my ($traits_idx, $traits);
+ if (($traits_idx = firstidx { ($traits) = /^traits=(\S*)\z/ } @args) != -1) {
+ my @traits = split /,/ => $traits;
+
+ $self->traits(\@traits);
+
+ $helper->{traits} = '['
+ .(join ',' => map { qq{'$_'} } @traits)
+ .']';
+
+ splice @args, $traits_idx, 1, ();
+ }
+
+ if ($args[0] && $args[0] =~ /^create=(\S*)\z/) {
+ $self->create($1);
+ shift @args;
+
+ if (@args) {
+ $self->_parse_loader_args(\@args);
+
+ $helper->{loader_args} = $self->_build_helper_loader_args;
+ }
+ }
+
+ my $dbi_dsn_part;
+ if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) {
+ die
+qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)}
+ if $dbi_dsn_part ne 'dbi';
+
+ $helper->{setup_connect_info} = 1;
+
+ $helper->{connect_info} =
+ $self->_build_helper_connect_info(\@args);
+
+ $self->_parse_connect_info(\@args);
+ }
+
+ $helper->{generator} = ref $self;
+ $helper->{generator_version} = $VERSION;
+}
+
+=head2 run
+
+Can be called on an instance to generate the files.
+
+=cut
+
+sub run {
+ my $self = shift;
+
+ if ($self->create eq 'dynamic') {
+ $self->_print_dynamic_deprecation_warning;
+ $self->_gen_dynamic_schema;
+ } elsif ($self->create eq 'static') {
+ $self->_gen_static_schema;
+ }
+
+ $self->_gen_model;
+}
+
+sub _parse_loader_args {
+ my ($self, $args) = @_;
+
+ my %loader_args = $self->_read_loader_args($args);
+
+ while (my ($key, $val) = each %loader_args) {
+ next if $key =~ /^(?:components|constraint|exclude)\z/;
+
+ $loader_args{$key} = $self->_eval($val);
+ die "syntax error for loader args key '$key' with value '$val': $@"
+ if $@;
+ }
+
+ my @components = $self->_build_loader_components(
+ delete $loader_args{components},
+ $loader_args{use_namespaces},
+ );
+
+ $self->components(\@components);
+
+ for my $re_opt (qw/constraint exclude/) {
+ $loader_args{$re_opt} = qr/$loader_args{$re_opt}/
+ if exists $loader_args{$re_opt};
+ }
+
+ tie my %result, 'Tie::IxHash';
+
+ %result = (
+ relationships => 1,
+ use_moose => $self->is_moose_schema ? 1 : 0,
+ col_collision_map => 'column_%s',
+ (!$self->old_schema ? (
+ use_namespaces => 1
+ ) : ()),
+ (@components ? (
+ components => \@components
+ ) : ()),
+ (%loader_args ? %loader_args : ()),
+ );
+
+ $self->loader_args(\%result);
+
+ wantarray ? %result : \%result;
+}
+
+sub _read_loader_args {
+ my ($self, $args) = @_;
+
+ my %loader_args;
+
+ while (@$args && $args->[0] !~ /^dbi:/i) {
+ my ($key, $val) = split /=/, shift(@$args), 2;
+
+ if ($self->_is_struct($val)) {
+ $loader_args{$key} = $val;
+ } elsif ((my @vals = split /,/ => $val) > 1) {
+ $loader_args{$key} = \@vals;
+ } else {
+ $loader_args{$key} = $val;
+ }
+ }
+
+ wantarray ? %loader_args : \%loader_args;
+}
+
+sub _build_helper_loader_args {
+ my $self = shift;
+
+ my $args = $self->loader_args;
+
+ tie my %loader_args, 'Tie::IxHash';
+
+ while (my ($arg, $val) = each %$args) {
+ if (ref $val) {
+ $loader_args{$arg} = $self->_data_struct_to_string($val);
+ } else {
+ $loader_args{$arg} = qq{'$val'};
+ }
+ }
+
+ \%loader_args
+}
+
+sub _build_loader_components {
+ my ($self, $components, $use_namespaces) = @_;
+
+ my @components = $self->old_schema && (not $use_namespaces) ? ()
+ : ('InflateColumn::DateTime');
+
+ if ($components) {
+ $components = [ $components ] if !ref $components;
+ push @components, @$components;
+ }
+
+ wantarray ? @components : \@components;
+}
+
+sub _build_helper_connect_info {
+ my ($self, $connect_info) = @_;
+
+ my @connect_info = @$connect_info;
+
+ my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info);
+
+ tie my %helper_connect_info, 'Tie::IxHash';
+
+ %helper_connect_info = (
+ dsn => qq{'$dsn'},
+ user => qq{'$user'},
+ password => qq{'$password'}
+ );
+
+ for (@connect_info) {
+ if (/^\s*{.*}\s*\z/) {
+ my $hash = $self->_eval($_);
+ die "Syntax errorr in connect_info hash: $_: $@" if $@;
+ my %hash = %$hash;
+
+ for my $key (keys %hash) {
+ my $val = $hash{$key};
+
+ if (ref $val) {
+ $val = $self->_data_struct_to_string($val);
+ } else {
+ $val = $self->_quote($val);
+ }
+
+ $helper_connect_info{$key} = $val;
+ }
+
+ next;
+ }
+
+ my ($key, $val) = split /=/, $_, 2;
+
+ if ($key eq 'quote_char') {
+ $helper_connect_info{$key} = length($val) == 1 ?
+ $self->_quote($val) :
+ $self->_data_struct_to_string([split //, $val]);
+ } else {
+ $helper_connect_info{$key} = $self->_quote_unless_struct($val);
+ }
+ }
+
+ \%helper_connect_info
+}
+
+sub _build_old_schema {
+ my $self = shift;
+
+ return $self->result_namespace eq '' ? 1 : 0;
+}
+
+sub _build_is_moose_schema {
+ my $self = shift;
+
+ my @schema_parts = split '::', $self->schema_class;
+
+ my $result_dir = File::Spec->catfile(
+ $self->helper->{base}, 'lib', @schema_parts, $self->result_namespace
+ );
+
+ # assume yes for new schemas
+ return 1 if not -d $result_dir;
+
+ my $uses_moose = 1;
+
+ my $cwd = getcwd;
+
+ try {
+ finddepth(sub {
+ return if $File::Find::name !~ /\.pm\z/;
+
+ open my $fh, '<', $File::Find::name
+ or die "Could not open $File::Find::name: $!";
+
+ my $code = do { local $/; <$fh> };
+ close $fh;
+
+ $uses_moose = 0 if $code !~ /\nuse Moose;\n/;
+
+ die;
+ }, $result_dir);
+ };
+
+ chdir $cwd;
+
+ return $uses_moose;
+}
+
+sub _build_result_namespace {
+ my $self = shift;
+
+ my @schema_parts = split '::', $self->schema_class;
+ my $schema_pm =
+ File::Spec->catfile($self->helper->{base}, 'lib', @schema_parts) . '.pm';
+
+ if (not -f $schema_pm) {
+ eval { Class::MOP::load_class('DBIx::Class::Schema::Loader') };
+
+ return 'Result' if $@;
+
+ return (try { DBIx::Class::Schema::Loader->VERSION('0.05') }) ? 'Result' : '';
+ }
+
+ open my $fh, '<', $schema_pm or die "Could not open $schema_pm: $!";
+ my $code = do { local $/; <$fh> };
+ close $fh;
+
+ my ($result_namespace) = $code =~ /result_namespace => '([^']+)'/;
+
+ return $result_namespace if $result_namespace;
+
+ return '' if $code =~ /->load_classes/;
+
+ return 'Result';
+}
+
+sub _data_struct_to_string {
+ my ($self, $data) = @_;
+
+ local $Data::Dumper::Terse = 1;
+ local $Data::Dumper::Quotekeys = 0;
+ local $Data::Dumper::Indent = 0;
+ local $Data::Dumper::Useqq = 1;
+
+ return Data::Dumper->Dump([$data]);
+}
+
+sub _get_dsn_user_pass {
+ my ($self, $connect_info) = @_;
+
+ my $dsn = shift @$connect_info;
+ my ($user, $password);
+
+ if ($dsn =~ /sqlite/i) {
+ ($user, $password) = ('', '');
+ shift @$connect_info while @$connect_info and $connect_info->[0] eq '';
+ } else {
+ ($user, $password) = splice @$connect_info, 0, 2;
+ }
+
+ ($dsn, $user, $password)
+}
+
+sub _parse_connect_info {
+ my ($self, $connect_info) = @_;
+
+ my @connect_info = @$connect_info;
+
+ my ($dsn, $user, $password) = $self->_get_dsn_user_pass(\@connect_info);
+
+ tie my %connect_info, 'Tie::IxHash';
+ @connect_info{qw/dsn user password/} = ($dsn, $user, $password);
+
+ for (@connect_info) {
+ if (/^\s*{.*}\s*\z/) {
+ my $hash = $self->_eval($_);
+ die "Syntax errorr in connect_info hash: $_: $@" if $@;
+
+ %connect_info = (%connect_info, %$hash);
+
+ next;
+ }
+
+ my ($key, $val) = split /=/, $_, 2;
+
+ if ($key eq 'quote_char') {
+ $connect_info{$key} = length($val) == 1 ? $val : [split //, $val];
+ } elsif ($key =~ /^(?:name_sep|limit_dialect)\z/) {
+ $connect_info{$key} = $val;
+ } else {
+ $connect_info{$key} = $self->_eval($val);
+ }
+
+ die "syntax error for connect_info key '$key' with value '$val': $@"
+ if $@;
+ }
+
+ $self->connect_info(\%connect_info);
+
+ \%connect_info
+}
+
+sub _is_struct {
+ my ($self, $val) = @_;
+
+ return $val =~ /^\s*(?:sub|[[{])/;
+}
+
+sub _quote {
+ my ($self, $val) = @_;
+
+ return 'q{'.$val.'}';
+}
+
+sub _quote_unless_struct {
+ my ($self, $val) = @_;
+
+ $val = $self->_quote($val) if not $self->_is_struct($val);
+
+ return $val;
+}
+
+sub _eval {
+ my ($self, $code) = @_;
+
+ return $code if looks_like_number $code;
+
+ return $code if not $self->_is_struct($code);
+
+ return eval "{no strict; $code}";
+}
+
+sub _gen_dynamic_schema {
+ my $self = shift;
+
+ my $helper = $self->helper;
+
+ my @schema_parts = split(/\:\:/, $self->schema_class);
+ my $schema_file_part = pop @schema_parts;
+
+ my $schema_dir = File::Spec->catfile(
+ $helper->{base}, 'lib', @schema_parts
+ );
+ my $schema_file = File::Spec->catfile(
+ $schema_dir, $schema_file_part . '.pm'
+ );
+
+ $helper->mk_dir($schema_dir);
+ $helper->render_file('schemaclass', $schema_file);
+}
+
+sub _gen_static_schema {
+ my $self = shift;
+
+ die "cannot load schema without connect info" unless $self->connect_info;
+
+ my $helper = $self->helper;
+
+ my $schema_dir = File::Spec->catfile($helper->{base}, 'lib');
+
+ try {
+ Class::MOP::load_class('DBIx::Class::Schema::Loader')
+ }
+ catch {
+ die "Cannot load DBIx::Class::Schema::Loader: $_";
+ };
+
+ DBIx::Class::Schema::Loader->import(
+ "dump_to_dir:$schema_dir", 'make_schema_at'
+ );
+
+ make_schema_at(
+ $self->schema_class,
+ $self->loader_args,
+ [$self->connect_info]
+ );
+}
+
+sub _gen_model {
+ my $self = shift;
+ my $helper = $self->helper;
+
+ $helper->render_file('compclass', $helper->{file} );
+}
+
+sub _print_dynamic_deprecation_warning {
+ warn <<EOF;
+************************************ WARNING **********************************
+* create=dynamic is DEPRECATED, please use create=static instead. *
+*******************************************************************************
+EOF
+ print "Continue? [y/n]: ";
+ chomp(my $response = <STDIN>);
+ exit 0 if $response =~ /^n(o)?\z/;
+}
+
+sub _cleanup_args {
+ my ($self, $args) = @_;
+
+# remove blanks, ie. someoned doing foo \ bar
+ my @res = grep !/^\s+\z/, @$args;
+
+# remove leading whitespace, ie. foo \ bar
+ s/^\s*// for @res;
+
+ @res
+}
+
+=head1 SEE ALSO
+
+General Catalyst Stuff:
+
+L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
+L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
+
+Stuff related to DBIC and this Model style:
+
+L<DBIx::Class>, L<DBIx::Class::Schema>,
+L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>
+
+=head1 AUTHOR
+
+See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
+L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
+
+=head1 COPYRIGHT
+
+See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
+__DATA__
+
+=begin pod_to_ignore
+
+__schemaclass__
+package [% schema_class %];
+
+use strict;
+use base qw/DBIx::Class::Schema::Loader/;
+
+__PACKAGE__->loader_options(
+ [%- FOREACH key = loader_args.keys %]
+ [% key %] => [% loader_args.${key} %],
+ [%- END -%]
+
+);
+
+=head1 NAME
+
+[% schema_class %] - L<DBIx::Class::Schema::Loader> class
+
+=head1 SYNOPSIS
+
+See L<[% app %]>
+
+=head1 DESCRIPTION
+
+Dynamic L<DBIx::Class::Schema::Loader> schema for use in L<[% class %]>
+
+=head1 GENERATED BY
+
+[% generator %] - [% generator_version %]
+
+=head1 AUTHOR
+
+[% author.replace(',+$', '') %]
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
+__compclass__
+package [% class %];
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => '[% schema_class %]',
+ [% IF traits %]traits => [% traits %],[% END %]
+ [% IF setup_connect_info %]connect_info => {
+ [%- FOREACH key = connect_info.keys %]
+ [% key %] => [% connect_info.${key} %],
+ [%- END -%]
+
+ }[% END %]
+);
+
+=head1 NAME
+
+[% class %] - Catalyst DBIC Schema Model
+
+=head1 SYNOPSIS
+
+See L<[% app %]>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<[% schema_class %]>
+
+=head1 GENERATED BY
+
+[% generator %] - [% generator_version %]
+
+=head1 AUTHOR
+
+[% author.replace(',+$', '') %]
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+__END__
+# vim:sts=4 sw=4:
Deleted: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm 2011-04-29 12:50:12 UTC (rev 14007)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -1,691 +0,0 @@
-package Catalyst::Model::DBIC::Schema;
-
-use Moose;
-use mro 'c3';
-extends 'Catalyst::Model';
-with 'CatalystX::Component::Traits';
-
-our $VERSION = '0.48';
-$VERSION = eval $VERSION;
-
-use namespace::autoclean;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
-use Data::Dumper;
-use DBIx::Class ();
-
-use Catalyst::Model::DBIC::Schema::Types
- qw/ConnectInfo LoadedClass SchemaClass Schema/;
-
-use MooseX::Types::Moose qw/ArrayRef Str ClassName Undef/;
-
-=head1 NAME
-
-Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
-
-=head1 SYNOPSIS
-
-First, prepare your database schema using L<DBIx::Class>, see
-L<Catalyst::Helper::Model::DBIC::Schema> for how to generate a
-L<DBIx::Class::Schema> from your database using the Helper script, and
-L<DBIx::Class::Schema::Loader::Base>.
-
-A typical usage of the helper script would be:
-
- script/myapp_create.pl model FilmDB DBIC::Schema MyApp::Schema::FilmDB \
- create=static dbi:mysql:filmdb dbusername dbpass \
- quote_char='`' name_sep='.'
-
-If you are unfamiliar with L<DBIx::Class>, see L<DBIx::Class::Manual::Intro>
-first.
-
-These examples assume that you already have a schema called
-C<MyApp::Schema::FilmDB>, which defines some Result classes for tables in
-C<MyApp::Schema::FilmDB::Result::Actor> and
-C<MyApp::Schema::FilmDB::Result::Film>. Either created by the helper script (as
-shown above) or manually.
-
-The helper also creates a Model in C<lib/MyApp/Model/FilmDB.pm>, if you already
-have a schema you can create just the Model using:
-
- script/myapp_create.pl model FilmDB DBIC::Schema MyApp::Schema::FilmDB
- dbi:mysql:filmdb dbusername dbpass
-
-The connect_info is optional and will be hardcoded into the Model if provided.
-It's better to configure it in your L<Catalyst> config file, which will also
-override any hardcoded config, see L</connect_info> for examples.
-
-Now you have a working Model which accesses your separate DBIC Schema. This can
-be used/accessed in the normal Catalyst manner, via C<< $c->model() >>:
-
- my $db_model = $c->model('FilmDB'); # a Catalyst::Model
- my $dbic = $c->model('FilmDB')->schema; # the actual DBIC object
-
-There is also a shortcut, which returns a L<DBIx::Class::ResultSet> directly,
-instead of a L<Catalyst::Model>:
-
- my $rs = $c->model('FilmDB::Actor');
-
-See L<DBIx::Class::ResultSet> to find out more about which methods can be
-called on ResultSets.
-
-You can also define your own ResultSet methods to encapsulate the
-database/business logic of your applications. These go into, for example,
-C<lib/MyApp/Schema/FilmDB/ResultSet/Actor.pm>. The class must inherit from
-L<DBIx::Class::ResultSet> and is automatically loaded.
-
-Then call your methods like any other L<DBIx::Class::ResultSet> method:
-
- $c->model('FilmDB::Actor')->SAG_members
-
-=head2 Some examples:
-
- # to access schema methods directly:
- $c->model('FilmDB')->schema->source(...);
-
- # to access the source object, resultset, and class:
- $c->model('FilmDB')->source(...);
- $c->model('FilmDB')->resultset(...);
- $c->model('FilmDB')->class(...);
-
- # For resultsets, there's an even quicker shortcut:
- $c->model('FilmDB::Actor')
- # is the same as $c->model('FilmDB')->resultset('Actor')
-
- # To get the composed schema for making new connections:
- my $newconn = $c->model('FilmDB')->composed_schema->connect(...);
-
- # Or the same thing via a convenience shortcut:
- my $newconn = $c->model('FilmDB')->connect(...);
-
- # or, if your schema works on different storage drivers:
- my $newconn = $c->model('FilmDB')->composed_schema->clone();
- $newconn->storage_type('::LDAP');
- $newconn->connection(...);
-
- # and again, a convenience shortcut
- my $newconn = $c->model('FilmDB')->clone();
- $newconn->storage_type('::LDAP');
- $newconn->connection(...);
-
-To set up authentication, see L</"Setting up DBIC authentication"> below.
-
-=head1 DESCRIPTION
-
-This is a Catalyst Model for L<DBIx::Class::Schema>-based Models. See
-the documentation for L<Catalyst::Helper::Model::DBIC::Schema> for
-information on generating these Models via Helper scripts.
-
-When your Catalyst app starts up, a thin Model layer is created as an interface
-to your DBIC Schema. It should be clearly noted that the model object returned
-by C<< $c->model('FilmDB') >> is NOT itself a DBIC schema or resultset object,
-but merely a wrapper proving L<methods|/METHODS> to access the underlying
-schema.
-
-In addition to this model class, a shortcut class is generated for each
-source in the schema, allowing easy and direct access to a resultset of the
-corresponding type. These generated classes are even thinner than the model
-class, providing no public methods but simply hooking into Catalyst's
-model() accessor via the
-L<ACCEPT_CONTEXT|Catalyst::Component/ACCEPT_CONTEXT> mechanism. The complete
-contents of each generated class is roughly equivalent to the following:
-
- package MyApp::Model::FilmDB::Actor
- sub ACCEPT_CONTEXT {
- my ($self, $c) = @_;
- $c->model('FilmDB')->resultset('Actor');
- }
-
-In short, there are three techniques available for obtaining a DBIC
-resultset object:
-
- # the long way
- my $rs = $c->model('FilmDB')->schema->resultset('Actor');
-
- # using the shortcut method on the model object
- my $rs = $c->model('FilmDB')->resultset('Actor');
-
- # using the generated class directly
- my $rs = $c->model('FilmDB::Actor');
-
-In order to add methods to a DBIC resultset, you cannot simply add them to
-the source (row, table) definition class; you must define a separate custom
-resultset class. This is just a matter of making a
-C<lib/MyApp/Schema/ResultSet/Actor.pm> class that inherits from
-L<DBIx::Class::ResultSet>, if you are using
-L<DBIx::Class::Schema/load_namespaces>, the default for helper script generated
-schemas.
-
-See L<DBIx::Class::Manual::Cookbook/"Predefined searches">
-for information on definining your own L<DBIx::Class::ResultSet> classes for
-use with L<DBIx::Class::Schema/load_classes>, the old default.
-
-=head1 CONFIG PARAMETERS
-
-=head2 schema_class
-
-This is the classname of your L<DBIx::Class::Schema> Schema. It needs
-to be findable in C<@INC>, but it does not need to be inside the
-C<Catalyst::Model::> namespace. This parameter is required.
-
-=head2 connect_info
-
-This is an arrayref of connection parameters, which are specific to your
-C<storage_type> (see your storage type documentation for more details).
-If you only need one parameter (e.g. the DSN), you can just pass a string
-instead of an arrayref.
-
-This is not required if C<schema_class> already has connection information
-defined inside itself (which isn't highly recommended, but can be done)
-
-For L<DBIx::Class::Storage::DBI>, which is the only supported
-C<storage_type> in L<DBIx::Class> at the time of this writing, the
-parameters are your dsn, username, password, and connect options hashref.
-
-See L<DBIx::Class::Storage::DBI/connect_info> for a detailed explanation
-of the arguments supported.
-
-Examples:
-
- connect_info => {
- dsn => 'dbi:Pg:dbname=mypgdb',
- user => 'postgres',
- password => ''
- }
-
- connect_info => {
- dsn => 'dbi:SQLite:dbname=foo.db',
- on_connect_do => [
- 'PRAGMA synchronous = OFF',
- ]
- }
-
- connect_info => {
- dsn => 'dbi:Pg:dbname=mypgdb',
- user => 'postgres',
- password => '',
- pg_enable_utf8 => 1,
- on_connect_do => [
- 'some SQL statement',
- 'another SQL statement',
- ],
- }
-
-Or using L<Config::General>:
-
- <Model::FilmDB>
- schema_class MyApp::Schema::FilmDB
- traits Caching
- <connect_info>
- dsn dbi:Pg:dbname=mypgdb
- user postgres
- password ""
- auto_savepoint 1
- quote_char """
- on_connect_do some SQL statement
- on_connect_do another SQL statement
- </connect_info>
- user_defined_schema_accessor foo
- </Model::FilmDB>
-
-or
-
- <Model::FilmDB>
- schema_class MyApp::Schema::FilmDB
- connect_info dbi:SQLite:dbname=foo.db
- </Model::FilmDB>
-
-Or using L<YAML>:
-
- Model::MyDB:
- schema_class: MyDB
- traits: Caching
- connect_info:
- dsn: dbi:Oracle:mydb
- user: mtfnpy
- password: mypass
- LongReadLen: 1000000
- LongTruncOk: 1
- on_connect_call: 'datetime_setup'
- quote_char: '"'
-
-The old arrayref style with hashrefs for L<DBI> then L<DBIx::Class> options is also
-supported:
-
- connect_info => [
- 'dbi:Pg:dbname=mypgdb',
- 'postgres',
- '',
- {
- pg_enable_utf8 => 1,
- },
- {
- auto_savepoint => 1,
- on_connect_do => [
- 'some SQL statement',
- 'another SQL statement',
- ],
- }
- ]
-
-=head2 traits
-
-Array of Traits to apply to the instance. Traits are L<Moose::Role>s.
-
-They are relative to the C<< MyApp::TraitFor::Model::DBIC::Schema:: >>, then
-the C<< Catalyst::TraitFor::Model::DBIC::Schema:: >> namespaces, unless
-prefixed with C<+> in which case they are taken to be a fully qualified name.
-E.g.:
-
- traits Caching
- traits +MyApp::TraitFor::Model::Foo
-
-A new instance is created at application time, so any consumed required
-attributes, coercions and modifiers will work.
-
-Traits are applied at L<Catalyst::Component/COMPONENT> time using
-L<CatalystX::Component::Traits>.
-
-C<ref $self> will be an anon class if any traits are applied, C<<
-$self->_original_class_name >> will be the original class.
-
-When writing a Trait, interesting points to modify are C<BUILD>, L</setup> and
-L</ACCEPT_CONTEXT>.
-
-Traits that come with the distribution:
-
-=over 4
-
-=item L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>
-
-=item L<Catalyst::TraitFor::Model::DBIC::Schema::Replicated>
-
-=item L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy>
-
-=back
-
-=head2 storage_type
-
-Allows the use of a different C<storage_type> than what is set in your
-C<schema_class> (which in turn defaults to C<::DBI> if not set in current
-L<DBIx::Class>). Completely optional, and probably unnecessary for most
-people until other storage backends become available for L<DBIx::Class>.
-
-=head1 ATTRIBUTES
-
-The keys you pass in the model configuration are available as attributes.
-
-Other attributes available:
-
-=head2 connect_info
-
-Your connect_info args normalized to hashref form (with dsn/user/password.) See
-L<DBIx::Class::Storage::DBI/connect_info> for more info on the hashref form of
-L</connect_info>.
-
-=head2 model_name
-
-The model name L<Catalyst> uses to resolve this model, the part after
-C<::Model::> or C<::M::> in your class name. E.g. if your class name is
-C<MyApp::Model::DB> the L</model_name> will be C<DB>.
-
-=head2 _default_cursor_class
-
-What to reset your L<DBIx::Class::Storage::DBI/cursor_class> to if a custom one
-doesn't work out. Defaults to L<DBIx::Class::Storage::DBI::Cursor>.
-
-=head1 ATTRIBUTES FROM L<MooseX::Traits::Pluggable>
-
-=head2 _original_class_name
-
-The class name of your model before any L</traits> are applied. E.g.
-C<MyApp::Model::DB>.
-
-=head2 _traits
-
-Unresolved arrayref of traits passed in the config.
-
-=head2 _resolved_traits
-
-Traits you used resolved to full class names.
-
-=head1 CONFIGURING YOUR SCHEMA AND RESULTSETS
-
-See the documentation for
-L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy> for instructions on how
-to pass config values from your L<Catalyst> config to your
-L<DBIx::Class::Schema> and/or L<DBIx::Class::ResultSet> classes.
-
-=head1 METHODS
-
-=head2 new
-
-Instantiates the Model based on the above-documented ->config parameters.
-The only required parameter is C<schema_class>. C<connect_info> is
-required in the case that C<schema_class> does not already have connection
-information defined for it.
-
-=head2 schema
-
-Accessor which returns the connected schema being used by the this model.
-There are direct shortcuts on the model class itself for
-schema->resultset, schema->source, and schema->class.
-
-=head2 composed_schema
-
-Accessor which returns the composed schema, which has no connection info,
-which was used in constructing the C<schema> above. Useful for creating
-new connections based on the same schema/model. There are direct shortcuts
-from the model object for composed_schema->clone and composed_schema->connect
-
-=head2 clone
-
-Shortcut for ->composed_schema->clone
-
-=head2 connect
-
-Shortcut for ->composed_schema->connect
-
-=head2 source
-
-Shortcut for ->schema->source
-
-=head2 class
-
-Shortcut for ->schema->class
-
-=head2 resultset
-
-Shortcut for ->schema->resultset
-
-=head2 txn_do
-
-Shortcut for ->schema->txn_do
-
-=head2 txn_scope_guard
-
-Shortcut for ->schema->txn_scope_guard
-
-=head2 storage
-
-Provides an accessor for the connected schema's storage object.
-
-See L<DBIx::Class::Storage> and L<DBIx::Class::Storage::DBI>.
-
-=cut
-
-has schema_class => (
- is => 'ro',
- isa => SchemaClass,
- coerce => 1,
- required => 1
-);
-
-has storage_type => (is => 'rw', isa => Str);
-
-has connect_info => (is => 'rw', isa => ConnectInfo, coerce => 1);
-
-has model_name => (
- is => 'ro',
- isa => Str,
- required => 1,
- lazy_build => 1,
-);
-
-has _default_cursor_class => (
- is => 'ro',
- isa => LoadedClass,
- default => 'DBIx::Class::Storage::DBI::Cursor',
- coerce => 1
-);
-
-has schema => (is => 'rw', isa => Schema);
-
-my $app_class;
-
-before COMPONENT => sub {
- $app_class = ref $_[1] || $_[1];
-};
-
-sub app_class { $app_class }
-
-sub BUILD {
- my ($self, $args) = @_;
- my $class = $self->_original_class_name;
- my $schema_class = $self->schema_class;
-
- if( !$self->connect_info ) {
- if($schema_class->storage && $schema_class->storage->connect_info) {
- $self->connect_info($schema_class->storage->connect_info);
- }
- else {
- die "Either ->config->{connect_info} must be defined for $class"
- . " or $schema_class must have connect info defined on it."
- . " Here's what we got:\n"
- . Dumper($args);
- }
- }
-
- if (exists $self->connect_info->{cursor_class}) {
- eval { Class::MOP::load_class($self->connect_info->{cursor_class}) }
- or croak "invalid connect_info: Cannot load your cursor_class"
- . " ".$self->connect_info->{cursor_class}.": $@";
- }
-
- $self->setup($args);
-
- my $is_installed = defined $self->composed_schema;
-
- $self->composed_schema($schema_class->compose_namespace($class))
- unless $is_installed;
-
- $self->schema($self->composed_schema->clone)
- unless $self->schema;
-
- $self->schema->storage_type($self->storage_type)
- if $self->storage_type;
-
- $self->schema->connection($self->connect_info);
-
- $self->_install_rs_models unless $is_installed;
-}
-
-sub clone { shift->composed_schema->clone(@_); }
-
-sub connect { shift->composed_schema->connect(@_); }
-
-# some proxy methods, see also SchemaProxy
-
-sub resultset { shift->schema->resultset(@_); }
-
-sub txn_do { shift->schema->txn_do(@_); }
-
-sub txn_scope_guard { shift->schema->txn_scope_guard(@_); }
-
-sub storage { shift->schema->storage(@_); }
-
-=head2 setup
-
-Called at C<BUILD> time before configuration, but after L</connect_info> is
-set. To do something after configuuration use C<< after BUILD => >>.
-
-Receives a hashref of args passed to C<BUILD>.
-
-=cut
-
-sub setup { 1 }
-
-=head2 ACCEPT_CONTEXT
-
-Point of extension for doing things at C<< $c->model >> time with context,
-returns the model instance, see L<Catalyst::Manual::Intro/ACCEPT_CONTEXT> for
-more information.
-
-=cut
-
-sub ACCEPT_CONTEXT { shift }
-
-sub _install_rs_models {
- my $self = shift;
- my $class = $self->_original_class_name;
-
- no strict 'refs';
-
- my @sources = $self->schema->sources;
-
- unless (@sources) {
- warn <<'EOF' unless $ENV{CMDS_NO_SOURCES};
-******************************* WARNING ***************************************
-* No sources found (did you forget to define your tables?) *
-* *
-* To turn off this warning, set the CMDS_NO_SOURCES environment variable. *
-*******************************************************************************
-EOF
- }
-
- foreach my $moniker (@sources) {
- my $classname = "${class}::$moniker";
- *{"${classname}::ACCEPT_CONTEXT"} = sub {
- shift;
- shift->model($self->model_name)->resultset($moniker);
- }
- }
-}
-
-sub _reset_cursor_class {
- my $self = shift;
-
- if ($self->storage->can('cursor_class')) {
- $self->storage->cursor_class($self->_default_cursor_class)
- if $self->storage->cursor_class ne $self->_default_cursor_class;
- }
-}
-
-{
- my %COMPOSED_CACHE;
-
- sub composed_schema {
- my $self = shift;
- my $class = $self->_original_class_name;
- my $store = \$COMPOSED_CACHE{$class}{$self->schema_class};
-
- $$store = shift if @_;
-
- return $$store
- }
-}
-
-sub _build_model_name {
- my $self = shift;
- my $class = $self->_original_class_name;
- (my $model_name = $class) =~ s/^[\w:]+::(?:Model|M):://;
-
- return $model_name;
-}
-
-__PACKAGE__->meta->make_immutable;
-
-=head1 ENVIRONMENT
-
-=over 4
-
-=item CMDS_NO_SOURCES
-
-Set this variable if you will be using schemas with no sources (Result classes)
-to disable the warning. The warning is there because having no Result classes
-is usually a mistake.
-
-=back
-
-=head1 Setting up DBIC authentication
-
-You can set this up with
-L<Catalyst::Authentication::Store::DBIx::Class> in MyApp.pm:
-
- package MyApp;
-
- use Catalyst qw/... Authentication .../;
-
- ...
-
- __PACKAGE__->config('Plugin::Authentication' =>
- {
- default_realm => 'members',
- members => {
- credential => {
- class => 'Password',
- password_field => 'password',
- password_type => 'hashed'
- password_hash_type => 'SHA-256'
- },
- store => {
- class => 'DBIx::Class',
- user_model => 'DB::User',
- role_relation => 'roles',
- role_field => 'rolename',
- }
- }
- });
-
-=head1 METHOD PROXYING
-
-The automatic proxying to the underlying L<DBIx::Class::Schema> has been
-removed as of version C<0.34>, to enable this feature add C<SchemaProxy> to
-L</traits>.
-
-See L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy>.
-
-=head1 SEE ALSO
-
-General Catalyst Stuff:
-
-L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
-L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
-
-Stuff related to DBIC and this Model style:
-
-L<DBIx::Class>, L<DBIx::Class::Schema>,
-L<DBIx::Class::Schema::Loader>, L<Catalyst::Helper::Model::DBIC::Schema>,
-L<CatalystX::Component::Traits>, L<MooseX::Traits::Pluggable>
-
-Traits:
-
-L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>,
-L<Catalyst::TraitFor::Model::DBIC::Schema::Replicated>,
-L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy>,
-L<Catalyst::TraitFor::Model::DBIC::Schema::QueryLog>
-
-=head1 AUTHOR
-
-Brandon L Black C<blblack at gmail.com>
-
-=head1 CONTRIBUTORS
-
-caelum: Rafael Kitover C<rkitover at cpan.org>
-
-dandv: Dan Dascalescu C<dandv at cpan.org>
-
-bluefeet: Aran Deltac C<bluefeet at cpan.org>
-
-t0m: Tomas Doran C<bobtfish at bobtfish.net>
-
-osfameron: C<osfameron at cpan.org>
-
-ozum: Ozum Eldogan C<ozum at ozum.net>
-
-Pavel I. Shaydo C<zwon at trinitum.org>
-
-=head1 COPYRIGHT
-
-Copyright (c) 2006 - 2010
-the Catalyst::Model::DBIC::Schema L</AUTHOR> and L</CONTRIBUTORS>
-as listed above.
-
-=head1 LICENSE
-
-This program is free software. You can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-=cut
-
-1;
-# vim:sts=4 sw=4 et tw=80:
Copied: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm (from rev 14010, Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/Model/DBIC/Schema.pm)
===================================================================
--- Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm (rev 0)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/Model/DBIC/Schema.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -0,0 +1,690 @@
+package Catalyst::Model::DBIC::Schema;
+
+use Moose;
+use mro 'c3';
+extends 'Catalyst::Model';
+with 'CatalystX::Component::Traits';
+
+our $VERSION = '0.49';
+$VERSION = eval $VERSION;
+
+use namespace::autoclean;
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use Data::Dumper;
+use DBIx::Class ();
+
+use Catalyst::Model::DBIC::Schema::Types
+ qw/ConnectInfo LoadedClass SchemaClass Schema/;
+
+use MooseX::Types::Moose qw/ArrayRef Str ClassName Undef/;
+
+=head1 NAME
+
+Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
+
+=head1 SYNOPSIS
+
+First, prepare your database schema using L<DBIx::Class>, see
+L<Catalyst::Helper::Model::DBIC::Schema> for how to generate a
+L<DBIx::Class::Schema> from your database using the Helper script, and
+L<DBIx::Class::Schema::Loader::Base>.
+
+A typical usage of the helper script would be:
+
+ script/myapp_create.pl model FilmDB DBIC::Schema MyApp::Schema::FilmDB \
+ create=static dbi:mysql:filmdb dbusername dbpass \
+ quote_names=1
+
+If you are unfamiliar with L<DBIx::Class>, see L<DBIx::Class::Manual::Intro>
+first.
+
+These examples assume that you already have a schema called
+C<MyApp::Schema::FilmDB>, which defines some Result classes for tables in
+C<MyApp::Schema::FilmDB::Result::Actor> and
+C<MyApp::Schema::FilmDB::Result::Film>. Either created by the helper script (as
+shown above) or manually.
+
+The helper also creates a Model in C<lib/MyApp/Model/FilmDB.pm>, if you already
+have a schema you can create just the Model using:
+
+ script/myapp_create.pl model FilmDB DBIC::Schema MyApp::Schema::FilmDB
+ dbi:mysql:filmdb dbusername dbpass
+
+The connect_info is optional and will be hardcoded into the Model if provided.
+It's better to configure it in your L<Catalyst> config file, which will also
+override any hardcoded config, see L</connect_info> for examples.
+
+Now you have a working Model which accesses your separate DBIC Schema. This can
+be used/accessed in the normal Catalyst manner, via C<< $c->model() >>:
+
+ my $db_model = $c->model('FilmDB'); # a Catalyst::Model
+ my $dbic = $c->model('FilmDB')->schema; # the actual DBIC object
+
+There is also a shortcut, which returns a L<DBIx::Class::ResultSet> directly,
+instead of a L<Catalyst::Model>:
+
+ my $rs = $c->model('FilmDB::Actor');
+
+See L<DBIx::Class::ResultSet> to find out more about which methods can be
+called on ResultSets.
+
+You can also define your own ResultSet methods to encapsulate the
+database/business logic of your applications. These go into, for example,
+C<lib/MyApp/Schema/FilmDB/ResultSet/Actor.pm>. The class must inherit from
+L<DBIx::Class::ResultSet> and is automatically loaded.
+
+Then call your methods like any other L<DBIx::Class::ResultSet> method:
+
+ $c->model('FilmDB::Actor')->SAG_members
+
+=head2 Some examples:
+
+ # to access schema methods directly:
+ $c->model('FilmDB')->schema->source(...);
+
+ # to access the source object, resultset, and class:
+ $c->model('FilmDB')->source(...);
+ $c->model('FilmDB')->resultset(...);
+ $c->model('FilmDB')->class(...);
+
+ # For resultsets, there's an even quicker shortcut:
+ $c->model('FilmDB::Actor')
+ # is the same as $c->model('FilmDB')->resultset('Actor')
+
+ # To get the composed schema for making new connections:
+ my $newconn = $c->model('FilmDB')->composed_schema->connect(...);
+
+ # Or the same thing via a convenience shortcut:
+ my $newconn = $c->model('FilmDB')->connect(...);
+
+ # or, if your schema works on different storage drivers:
+ my $newconn = $c->model('FilmDB')->composed_schema->clone();
+ $newconn->storage_type('::LDAP');
+ $newconn->connection(...);
+
+ # and again, a convenience shortcut
+ my $newconn = $c->model('FilmDB')->clone();
+ $newconn->storage_type('::LDAP');
+ $newconn->connection(...);
+
+To set up authentication, see L</"Setting up DBIC authentication"> below.
+
+=head1 DESCRIPTION
+
+This is a Catalyst Model for L<DBIx::Class::Schema>-based Models. See
+the documentation for L<Catalyst::Helper::Model::DBIC::Schema> for
+information on generating these Models via Helper scripts.
+
+When your Catalyst app starts up, a thin Model layer is created as an interface
+to your DBIC Schema. It should be clearly noted that the model object returned
+by C<< $c->model('FilmDB') >> is NOT itself a DBIC schema or resultset object,
+but merely a wrapper proving L<methods|/METHODS> to access the underlying
+schema.
+
+In addition to this model class, a shortcut class is generated for each
+source in the schema, allowing easy and direct access to a resultset of the
+corresponding type. These generated classes are even thinner than the model
+class, providing no public methods but simply hooking into Catalyst's
+model() accessor via the
+L<ACCEPT_CONTEXT|Catalyst::Component/ACCEPT_CONTEXT> mechanism. The complete
+contents of each generated class is roughly equivalent to the following:
+
+ package MyApp::Model::FilmDB::Actor
+ sub ACCEPT_CONTEXT {
+ my ($self, $c) = @_;
+ $c->model('FilmDB')->resultset('Actor');
+ }
+
+In short, there are three techniques available for obtaining a DBIC
+resultset object:
+
+ # the long way
+ my $rs = $c->model('FilmDB')->schema->resultset('Actor');
+
+ # using the shortcut method on the model object
+ my $rs = $c->model('FilmDB')->resultset('Actor');
+
+ # using the generated class directly
+ my $rs = $c->model('FilmDB::Actor');
+
+In order to add methods to a DBIC resultset, you cannot simply add them to
+the source (row, table) definition class; you must define a separate custom
+resultset class. This is just a matter of making a
+C<lib/MyApp/Schema/ResultSet/Actor.pm> class that inherits from
+L<DBIx::Class::ResultSet>, if you are using
+L<DBIx::Class::Schema/load_namespaces>, the default for helper script generated
+schemas.
+
+See L<DBIx::Class::Manual::Cookbook/"Predefined searches">
+for information on definining your own L<DBIx::Class::ResultSet> classes for
+use with L<DBIx::Class::Schema/load_classes>, the old default.
+
+=head1 CONFIG PARAMETERS
+
+=head2 schema_class
+
+This is the classname of your L<DBIx::Class::Schema> Schema. It needs
+to be findable in C<@INC>, but it does not need to be inside the
+C<Catalyst::Model::> namespace. This parameter is required.
+
+=head2 connect_info
+
+This is a hashref or arrayref of connection parameters, which are specific to
+your C<storage_type> (see your storage type documentation for more details). If
+you only need one parameter (e.g. the DSN), you can just pass a string.
+
+This is not required if C<schema_class> already has connection information
+defined inside itself (which isn't highly recommended, but can be done.)
+
+For L<DBIx::Class::Storage::DBI>, which is the only supported
+C<storage_type> in L<DBIx::Class> at the time of this writing, the
+parameters are your dsn, username, password, and connect options hashref.
+
+See L<DBIx::Class::Storage::DBI/connect_info> for a detailed explanation
+of the arguments supported.
+
+Examples:
+
+ connect_info => {
+ dsn => 'dbi:Pg:dbname=mypgdb',
+ user => 'postgres',
+ password => ''
+ }
+
+ connect_info => {
+ dsn => 'dbi:SQLite:dbname=foo.db',
+ on_connect_do => [
+ 'PRAGMA synchronous = OFF',
+ ]
+ }
+
+ connect_info => {
+ dsn => 'dbi:Pg:dbname=mypgdb',
+ user => 'postgres',
+ password => '',
+ pg_enable_utf8 => 1,
+ on_connect_do => [
+ 'some SQL statement',
+ 'another SQL statement',
+ ],
+ }
+
+Or using L<Config::General>:
+
+ <Model::FilmDB>
+ schema_class MyApp::Schema::FilmDB
+ traits Caching
+ <connect_info>
+ dsn dbi:Pg:dbname=mypgdb
+ user postgres
+ password ""
+ auto_savepoint 1
+ quote_names 1
+ on_connect_do some SQL statement
+ on_connect_do another SQL statement
+ </connect_info>
+ user_defined_schema_accessor foo
+ </Model::FilmDB>
+
+or
+
+ <Model::FilmDB>
+ schema_class MyApp::Schema::FilmDB
+ connect_info dbi:SQLite:dbname=foo.db
+ </Model::FilmDB>
+
+Or using L<YAML>:
+
+ Model::MyDB:
+ schema_class: MyDB
+ traits: Caching
+ connect_info:
+ dsn: dbi:Oracle:mydb
+ user: mtfnpy
+ password: mypass
+ LongReadLen: 1000000
+ LongTruncOk: 1
+ on_connect_call: 'datetime_setup'
+ quote_names: 1
+
+The old arrayref style with hashrefs for L<DBI> then L<DBIx::Class> options is also
+supported:
+
+ connect_info => [
+ 'dbi:Pg:dbname=mypgdb',
+ 'postgres',
+ '',
+ {
+ pg_enable_utf8 => 1,
+ },
+ {
+ auto_savepoint => 1,
+ on_connect_do => [
+ 'some SQL statement',
+ 'another SQL statement',
+ ],
+ }
+ ]
+
+=head2 traits
+
+Array of Traits to apply to the instance. Traits are L<Moose::Role>s.
+
+They are relative to the C<< MyApp::TraitFor::Model::DBIC::Schema:: >>, then
+the C<< Catalyst::TraitFor::Model::DBIC::Schema:: >> namespaces, unless
+prefixed with C<+> in which case they are taken to be a fully qualified name.
+E.g.:
+
+ traits Caching
+ traits +MyApp::TraitFor::Model::Foo
+
+A new instance is created at application time, so any consumed required
+attributes, coercions and modifiers will work.
+
+Traits are applied at L<Catalyst::Component/COMPONENT> time using
+L<CatalystX::Component::Traits>.
+
+C<ref $self> will be an anon class if any traits are applied, C<<
+$self->_original_class_name >> will be the original class.
+
+When writing a Trait, interesting points to modify are C<BUILD>, L</setup> and
+L</ACCEPT_CONTEXT>.
+
+Traits that come with the distribution:
+
+=over 4
+
+=item L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>
+
+=item L<Catalyst::TraitFor::Model::DBIC::Schema::Replicated>
+
+=item L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy>
+
+=back
+
+=head2 storage_type
+
+Allows the use of a different C<storage_type> than what is set in your
+C<schema_class> (which in turn defaults to C<::DBI> if not set in current
+L<DBIx::Class>). Completely optional, and probably unnecessary for most
+people until other storage backends become available for L<DBIx::Class>.
+
+=head1 ATTRIBUTES
+
+The keys you pass in the model configuration are available as attributes.
+
+Other attributes available:
+
+=head2 connect_info
+
+Your connect_info args normalized to hashref form (with dsn/user/password.) See
+L<DBIx::Class::Storage::DBI/connect_info> for more info on the hashref form of
+L</connect_info>.
+
+=head2 model_name
+
+The model name L<Catalyst> uses to resolve this model, the part after
+C<::Model::> or C<::M::> in your class name. E.g. if your class name is
+C<MyApp::Model::DB> the L</model_name> will be C<DB>.
+
+=head2 _default_cursor_class
+
+What to reset your L<DBIx::Class::Storage::DBI/cursor_class> to if a custom one
+doesn't work out. Defaults to L<DBIx::Class::Storage::DBI::Cursor>.
+
+=head1 ATTRIBUTES FROM L<MooseX::Traits::Pluggable>
+
+=head2 _original_class_name
+
+The class name of your model before any L</traits> are applied. E.g.
+C<MyApp::Model::DB>.
+
+=head2 _traits
+
+Unresolved arrayref of traits passed in the config.
+
+=head2 _resolved_traits
+
+Traits you used resolved to full class names.
+
+=head1 CONFIGURING YOUR SCHEMA AND RESULTSETS
+
+See the documentation for
+L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy> for instructions on how
+to pass config values from your L<Catalyst> config to your
+L<DBIx::Class::Schema> and/or L<DBIx::Class::ResultSet> classes.
+
+=head1 METHODS
+
+=head2 new
+
+Instantiates the Model based on the above-documented ->config parameters.
+The only required parameter is C<schema_class>. C<connect_info> is
+required in the case that C<schema_class> does not already have connection
+information defined for it.
+
+=head2 schema
+
+Accessor which returns the connected schema being used by the this model.
+There are direct shortcuts on the model class itself for
+schema->resultset, schema->source, and schema->class.
+
+=head2 composed_schema
+
+Accessor which returns the composed schema, which has no connection info,
+which was used in constructing the C<schema> above. Useful for creating
+new connections based on the same schema/model. There are direct shortcuts
+from the model object for composed_schema->clone and composed_schema->connect
+
+=head2 clone
+
+Shortcut for ->composed_schema->clone
+
+=head2 connect
+
+Shortcut for ->composed_schema->connect
+
+=head2 source
+
+Shortcut for ->schema->source
+
+=head2 class
+
+Shortcut for ->schema->class
+
+=head2 resultset
+
+Shortcut for ->schema->resultset
+
+=head2 txn_do
+
+Shortcut for ->schema->txn_do
+
+=head2 txn_scope_guard
+
+Shortcut for ->schema->txn_scope_guard
+
+=head2 storage
+
+Provides an accessor for the connected schema's storage object.
+
+See L<DBIx::Class::Storage> and L<DBIx::Class::Storage::DBI>.
+
+=cut
+
+has schema_class => (
+ is => 'ro',
+ isa => SchemaClass,
+ coerce => 1,
+ required => 1
+);
+
+has storage_type => (is => 'rw', isa => Str);
+
+has connect_info => (is => 'rw', isa => ConnectInfo, coerce => 1);
+
+has model_name => (
+ is => 'ro',
+ isa => Str,
+ required => 1,
+ lazy_build => 1,
+);
+
+has _default_cursor_class => (
+ is => 'ro',
+ isa => LoadedClass,
+ default => 'DBIx::Class::Storage::DBI::Cursor',
+ coerce => 1
+);
+
+has schema => (is => 'rw', isa => Schema);
+
+my $app_class;
+
+before COMPONENT => sub {
+ $app_class = ref $_[1] || $_[1];
+};
+
+sub app_class { $app_class }
+
+sub BUILD {
+ my ($self, $args) = @_;
+ my $class = $self->_original_class_name;
+ my $schema_class = $self->schema_class;
+
+ if( !$self->connect_info ) {
+ if($schema_class->storage && $schema_class->storage->connect_info) {
+ $self->connect_info($schema_class->storage->connect_info);
+ }
+ else {
+ die "Either ->config->{connect_info} must be defined for $class"
+ . " or $schema_class must have connect info defined on it."
+ . " Here's what we got:\n"
+ . Dumper($args);
+ }
+ }
+
+ if (exists $self->connect_info->{cursor_class}) {
+ eval { Class::MOP::load_class($self->connect_info->{cursor_class}) }
+ or croak "invalid connect_info: Cannot load your cursor_class"
+ . " ".$self->connect_info->{cursor_class}.": $@";
+ }
+
+ $self->setup($args);
+
+ my $is_installed = defined $self->composed_schema;
+
+ $self->composed_schema($schema_class->compose_namespace($class))
+ unless $is_installed;
+
+ $self->schema($self->composed_schema->clone)
+ unless $self->schema;
+
+ $self->schema->storage_type($self->storage_type)
+ if $self->storage_type;
+
+ $self->schema->connection($self->connect_info);
+
+ $self->_install_rs_models unless $is_installed;
+}
+
+sub clone { shift->composed_schema->clone(@_); }
+
+sub connect { shift->composed_schema->connect(@_); }
+
+# some proxy methods, see also SchemaProxy
+
+sub resultset { shift->schema->resultset(@_); }
+
+sub txn_do { shift->schema->txn_do(@_); }
+
+sub txn_scope_guard { shift->schema->txn_scope_guard(@_); }
+
+sub storage { shift->schema->storage(@_); }
+
+=head2 setup
+
+Called at C<BUILD> time before configuration, but after L</connect_info> is
+set. To do something after configuuration use C<< after BUILD => >>.
+
+Receives a hashref of args passed to C<BUILD>.
+
+=cut
+
+sub setup { 1 }
+
+=head2 ACCEPT_CONTEXT
+
+Point of extension for doing things at C<< $c->model >> time with context,
+returns the model instance, see L<Catalyst::Manual::Intro/ACCEPT_CONTEXT> for
+more information.
+
+=cut
+
+sub ACCEPT_CONTEXT { shift }
+
+sub _install_rs_models {
+ my $self = shift;
+ my $class = $self->_original_class_name;
+
+ no strict 'refs';
+
+ my @sources = $self->schema->sources;
+
+ unless (@sources) {
+ warn <<'EOF' unless $ENV{CMDS_NO_SOURCES};
+******************************* WARNING ***************************************
+* No sources found (did you forget to define your tables?) *
+* *
+* To turn off this warning, set the CMDS_NO_SOURCES environment variable. *
+*******************************************************************************
+EOF
+ }
+
+ foreach my $moniker (@sources) {
+ my $classname = "${class}::$moniker";
+ *{"${classname}::ACCEPT_CONTEXT"} = sub {
+ shift;
+ shift->model($self->model_name)->resultset($moniker);
+ }
+ }
+}
+
+sub _reset_cursor_class {
+ my $self = shift;
+
+ if ($self->storage->can('cursor_class')) {
+ $self->storage->cursor_class($self->_default_cursor_class)
+ if $self->storage->cursor_class ne $self->_default_cursor_class;
+ }
+}
+
+{
+ my %COMPOSED_CACHE;
+
+ sub composed_schema {
+ my $self = shift;
+ my $class = $self->_original_class_name;
+ my $store = \$COMPOSED_CACHE{$class}{$self->schema_class};
+
+ $$store = shift if @_;
+
+ return $$store
+ }
+}
+
+sub _build_model_name {
+ my $self = shift;
+ my $class = $self->_original_class_name;
+ (my $model_name = $class) =~ s/^[\w:]+::(?:Model|M):://;
+
+ return $model_name;
+}
+
+__PACKAGE__->meta->make_immutable;
+
+=head1 ENVIRONMENT
+
+=over 4
+
+=item CMDS_NO_SOURCES
+
+Set this variable if you will be using schemas with no sources (Result classes)
+to disable the warning. The warning is there because having no Result classes
+is usually a mistake.
+
+=back
+
+=head1 Setting up DBIC authentication
+
+You can set this up with
+L<Catalyst::Authentication::Store::DBIx::Class> in MyApp.pm:
+
+ package MyApp;
+
+ use Catalyst qw/... Authentication .../;
+
+ ...
+
+ __PACKAGE__->config('Plugin::Authentication' =>
+ {
+ default_realm => 'members',
+ members => {
+ credential => {
+ class => 'Password',
+ password_field => 'password',
+ password_type => 'hashed'
+ password_hash_type => 'SHA-256'
+ },
+ store => {
+ class => 'DBIx::Class',
+ user_model => 'DB::User',
+ role_relation => 'roles',
+ role_field => 'rolename',
+ }
+ }
+ });
+
+=head1 METHOD PROXYING
+
+The automatic proxying to the underlying L<DBIx::Class::Schema> has been
+removed as of version C<0.34>, to enable this feature add C<SchemaProxy> to
+L</traits>.
+
+See L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy>.
+
+=head1 SEE ALSO
+
+General Catalyst Stuff:
+
+L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
+L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
+
+Stuff related to DBIC and this Model style:
+
+L<DBIx::Class>, L<DBIx::Class::Schema>,
+L<DBIx::Class::Schema::Loader>, L<Catalyst::Helper::Model::DBIC::Schema>,
+L<CatalystX::Component::Traits>, L<MooseX::Traits::Pluggable>
+
+Traits:
+
+L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>,
+L<Catalyst::TraitFor::Model::DBIC::Schema::Replicated>,
+L<Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy>,
+L<Catalyst::TraitFor::Model::DBIC::Schema::QueryLog>
+
+=head1 AUTHOR
+
+Brandon L Black C<blblack at gmail.com>
+
+=head1 CONTRIBUTORS
+
+caelum: Rafael Kitover C<rkitover at cpan.org>
+
+dandv: Dan Dascalescu C<dandv at cpan.org>
+
+bluefeet: Aran Deltac C<bluefeet at cpan.org>
+
+t0m: Tomas Doran C<bobtfish at bobtfish.net>
+
+osfameron: C<osfameron at cpan.org>
+
+ozum: Ozum Eldogan C<ozum at ozum.net>
+
+Pavel I. Shaydo C<zwon at trinitum.org>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2006 - 2010
+the Catalyst::Model::DBIC::Schema L</AUTHOR> and L</CONTRIBUTORS>
+as listed above.
+
+=head1 LICENSE
+
+This program is free software. You can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
+# vim:sts=4 sw=4 et tw=80:
Deleted: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm 2011-04-29 12:50:12 UTC (rev 14007)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -1,145 +0,0 @@
-package Catalyst::TraitFor::Model::DBIC::Schema::Replicated;
-
-use namespace::autoclean;
-use Moose::Role;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
-
-use Catalyst::Model::DBIC::Schema::Types qw/ConnectInfos LoadedClass/;
-use MooseX::Types::Moose qw/Str HashRef/;
-
-=head1 NAME
-
-Catalyst::TraitFor::Model::DBIC::Schema::Replicated - Replicated storage support for
-L<Catalyst::Model::DBIC::Schema>
-
-=head1 SYNOPSiS
-
- __PACKAGE__->config({
- traits => ['Replicated']
- connect_info =>
- ['dbi:mysql:master', 'user', 'pass'],
- replicants => [
- ['dbi:mysql:slave1', 'user', 'pass'],
- ['dbi:mysql:slave2', 'user', 'pass'],
- ['dbi:mysql:slave3', 'user', 'pass'],
- ],
- balancer_args => {
- master_read_weight => 0.3
- }
- });
-
-=head1 DESCRIPTION
-
-Sets your storage_type to L<DBIx::Class::Storage::DBI::Replicated> and connects
-replicants provided in config. See that module for supported resultset
-attributes.
-
-The default L<DBIx::Class::Storage::DBI::Replicated/balancer_type> is
-C<::Random>.
-
-Sets the
-L<DBIx::Class::Storage::DBI::Replicated::Balancer::Random/master_read_weight> to
-C<1> by default, meaning that you have the same chance of reading from master as
-you do from replicants. Set to C<0> to turn off reads from master.
-
-=head1 CONFIG PARAMETERS
-
-=head2 replicants
-
-Array of connect_info settings for every replicant.
-
-The following can be set via L<Catalyst::Model::DBIC::Schema/connect_info>, or
-as their own parameters. If set via separate parameters, they will override the
-settings in C<connect_info>.
-
-=head2 pool_type
-
-See L<DBIx::Class::Storage::DBI::Replicated/pool_type>.
-
-=head2 pool_args
-
-See L<DBIx::Class::Storage::DBI::Replicated/pool_args>.
-
-=head2 balancer_type
-
-See L<DBIx::Class::Storage::DBI::Replicated/balancer_type>.
-
-=head2 balancer_args
-
-See L<DBIx::Class::Storage::DBI::Replicated/balancer_args>.
-
-=cut
-
-has replicants => (
- is => 'ro', isa => ConnectInfos, coerce => 1, required => 1
-);
-
-has pool_type => (is => 'ro', isa => LoadedClass);
-has pool_args => (is => 'ro', isa => HashRef);
-has balancer_type => (is => 'ro', isa => Str);
-has balancer_args => (is => 'ro', isa => HashRef);
-
-after setup => sub {
- my $self = shift;
-
-# check storage_type compatibility (if configured)
- if (my $storage_type = $self->storage_type) {
- my $class = $storage_type =~ /^::/ ?
- "DBIx::Class::Storage$storage_type"
- : $storage_type;
-
- croak "This storage_type cannot be used with replication"
- unless $class->isa('DBIx::Class::Storage::DBI::Replicated');
- } else {
- $self->storage_type('::DBI::Replicated');
- }
-
- my $connect_info = $self->connect_info;
-
- $connect_info->{pool_type} = $self->pool_type
- if $self->pool_type;
-
- $connect_info->{pool_args} = $self->pool_args
- if $self->pool_args;
-
- $connect_info->{balancer_type} = $self->balancer_type ||
- $connect_info->{balancer_type} || '::Random';
-
- $connect_info->{balancer_args} = $self->balancer_args ||
- $connect_info->{balancer_args} || {};
-
- $connect_info->{balancer_args}{master_read_weight} = 1
- unless exists $connect_info->{balancer_args}{master_read_weight};
-};
-
-sub BUILD {}
-
-after BUILD => sub {
- my $self = shift;
-
- $self->storage->connect_replicants(map [ $_ ], @{ $self->replicants });
-};
-
-=head1 SEE ALSO
-
-L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class>,
-L<DBIx::Class::Storage::DBI::Replicated>,
-L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>
-
-=head1 AUTHOR
-
-See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
-L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
-
-=head1 COPYRIGHT
-
-See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
-
-=head1 LICENSE
-
-This program is free software, you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-=cut
-
-1;
Copied: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm (from rev 14009, Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm)
===================================================================
--- Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm (rev 0)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -0,0 +1,147 @@
+package Catalyst::TraitFor::Model::DBIC::Schema::Replicated;
+
+use namespace::autoclean;
+use Moose::Role;
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+
+use Catalyst::Model::DBIC::Schema::Types qw/ConnectInfos LoadedClass/;
+use MooseX::Types::Moose qw/Str HashRef/;
+
+=head1 NAME
+
+Catalyst::TraitFor::Model::DBIC::Schema::Replicated - Replicated storage support for
+L<Catalyst::Model::DBIC::Schema>
+
+=head1 SYNOPSiS
+
+ __PACKAGE__->config({
+ traits => ['Replicated']
+ connect_info =>
+ ['dbi:mysql:master', 'user', 'pass'],
+ replicants => [
+ ['dbi:mysql:slave1', 'user', 'pass'],
+ ['dbi:mysql:slave2', 'user', 'pass'],
+ ['dbi:mysql:slave3', 'user', 'pass'],
+ ],
+ balancer_args => {
+ master_read_weight => 0.3
+ }
+ });
+
+=head1 DESCRIPTION
+
+Sets your storage_type to L<DBIx::Class::Storage::DBI::Replicated> and connects
+replicants provided in config. See that module for supported resultset
+attributes.
+
+The default L<DBIx::Class::Storage::DBI::Replicated/balancer_type> is
+C<::Random>.
+
+Sets the
+L<DBIx::Class::Storage::DBI::Replicated::Balancer::Random/master_read_weight> to
+C<1> by default, meaning that you have the same chance of reading from master as
+you do from replicants. Set to C<0> to turn off reads from master.
+
+=head1 CONFIG PARAMETERS
+
+=head2 replicants
+
+Array of connect_info settings for every replicant.
+
+The following can be set via L<Catalyst::Model::DBIC::Schema/connect_info>, or
+as their own parameters. If set via separate parameters, they will override the
+settings in C<connect_info>.
+
+=head2 pool_type
+
+See L<DBIx::Class::Storage::DBI::Replicated/pool_type>.
+
+=head2 pool_args
+
+See L<DBIx::Class::Storage::DBI::Replicated/pool_args>.
+
+=head2 balancer_type
+
+See L<DBIx::Class::Storage::DBI::Replicated/balancer_type>.
+
+=head2 balancer_args
+
+See L<DBIx::Class::Storage::DBI::Replicated/balancer_args>.
+
+=cut
+
+has replicants => (
+ is => 'ro', isa => ConnectInfos, coerce => 1, required => 1
+);
+
+has pool_type => (is => 'ro', isa => LoadedClass);
+has pool_args => (is => 'ro', isa => HashRef);
+has balancer_type => (is => 'ro', isa => Str);
+has balancer_args => (is => 'ro', isa => HashRef);
+
+after setup => sub {
+ my $self = shift;
+
+# check storage_type compatibility (if configured)
+ if (my $storage_type = $self->storage_type) {
+ my $class = $storage_type =~ /^::/ ?
+ "DBIx::Class::Storage$storage_type"
+ : $storage_type;
+
+ Class::MOP::load_class($class);
+
+ croak "This storage_type cannot be used with replication"
+ unless $class->isa('DBIx::Class::Storage::DBI::Replicated');
+ } else {
+ $self->storage_type('::DBI::Replicated');
+ }
+
+ my $connect_info = $self->connect_info;
+
+ $connect_info->{pool_type} = $self->pool_type
+ if $self->pool_type;
+
+ $connect_info->{pool_args} = $self->pool_args
+ if $self->pool_args;
+
+ $connect_info->{balancer_type} = $self->balancer_type ||
+ $connect_info->{balancer_type} || '::Random';
+
+ $connect_info->{balancer_args} = $self->balancer_args ||
+ $connect_info->{balancer_args} || {};
+
+ $connect_info->{balancer_args}{master_read_weight} = 1
+ unless exists $connect_info->{balancer_args}{master_read_weight};
+};
+
+sub BUILD {}
+
+after BUILD => sub {
+ my $self = shift;
+
+ $self->storage->connect_replicants(map [ $_ ], @{ $self->replicants });
+};
+
+=head1 SEE ALSO
+
+L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class>,
+L<DBIx::Class::Storage::DBI::Replicated>,
+L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>
+
+=head1 AUTHOR
+
+See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
+L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
+
+=head1 COPYRIGHT
+
+See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
+
+=head1 LICENSE
+
+This program is free software, you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
Deleted: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm 2011-04-29 12:50:12 UTC (rev 14007)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -1,204 +0,0 @@
-package Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy;
-
-use namespace::autoclean;
-use Moose::Role;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
-use Catalyst::Model::DBIC::Schema::Types 'Schema';
-
-=head1 NAME
-
-Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy - Proxy Schema Methods and
-Options from Model
-
-=head1 DESCRIPTION
-
-Allows you to call your L<DBIx::Class::Schema> methods directly on the Model
-instance, and passes config options to your L<DBIx::Class::Schema> and
-L<DBIx::Class::ResultSet> attributes at C<BUILD> time.
-
-Methods and attributes local to your C<Model> take precedence over
-L<DBIx::Class::Schema> or L<DBIx::Class::ResultSet> methods and attributes.
-
-=head1 CREATING SCHEMA CONFIG ATTRIBUTES
-
-To create attributes in your C<Schema.pm>, use either Moose or
-L<Class::Accessor::Grouped>, which is inherited from by all L<DBIx::Class>
-classes automatically. E.g.:
-
- __PACKAGE__->mk_group_accessors(simple => qw/
- config_key1
- config_key2
- ...
- /);
-
-Or with L<Moose>:
-
- use Moose;
- has config_key1 => (is => 'rw', default => 'default_value');
-
-This code can be added after the md5sum on L<DBIx::Class::Schema::Loader>
-generated schemas.
-
-At app startup, any non-local options will be passed to these accessors, and can
-be accessed as usual via C<< $schema->config_key1 >>.
-
-These config values go into your C<Model::DB> block, along with normal config
-values.
-
-=head1 CREATING RESULTSET CONFIG ATTRIBUTES
-
-You can create classdata on L<DBIx::Class::ResultSet> classes to hold values
-from L<Catalyst> config.
-
-The code for this looks something like this:
-
- package MySchema::ResultSet::Foo;
-
- use base 'DBIx::Class::ResultSet';
-
- __PACKAGE__->mk_group_accessors(inherited => qw/
- rs_config_key1
- rs_config_key2
- ...
- /);
- __PACKAGE__->rs_config_key1('default_value');
-
-Or, if you prefer L<Moose>:
-
- package MySchema::ResultSet::Foo;
-
- use Moose;
- use MooseX::NonMoose;
- use MooseX::ClassAttribute;
- extends 'DBIx::Class::ResultSet';
-
- class_has rs_config_key1 => (is => 'rw', default => 'default_value');
-
-In your catalyst config, use the generated Model name as the config key, e.g.:
-
- <Model::DB::Users>
- strict_passwords 1
- </Model::DB::Users>
-
-=cut
-
-after setup => sub {
- my ($self, $args) = @_;
-
- my $schema = $self->schema;
-
- my $was_mutable = $self->meta->is_mutable;
-
- $self->meta->make_mutable;
- $self->meta->add_attribute('schema',
- is => 'rw',
- isa => Schema,
- handles => $self->_delegates # this removes the attribute too
- );
- $self->meta->make_immutable unless $was_mutable;
-
- $self->schema($schema) if $schema;
-};
-
-after BUILD => sub {
- my ($self, $args) = @_;
-
- $self->_pass_options_to_schema($args);
-
- for my $source ($self->schema->sources) {
- my $config_key = 'Model::' . $self->model_name . '::' . $source;
- my $config = $self->app_class->config->{$config_key};
- next unless $config;
- $self->_pass_options_to_resultset($source, $config);
- }
-};
-
-sub _delegates {
- my $self = shift;
-
- my $schema_meta = Class::MOP::Class->initialize($self->schema_class);
- my @schema_methods = $schema_meta->get_all_method_names;
-
-# combine with any already added by other schemas
- my @handles = eval {
- @{ $self->meta->find_attribute_by_name('schema')->handles }
- };
-
-# now kill the attribute, otherwise add_attribute in BUILD will not do the right
-# thing (it clears the handles for some reason.) May be a Moose bug.
- eval { $self->meta->remove_attribute('schema') };
-
- my %schema_methods;
- @schema_methods{ @schema_methods, @handles } = ();
- @schema_methods = keys %schema_methods;
-
- my @my_methods = $self->meta->get_all_method_names;
- my %my_methods;
- @my_methods{@my_methods} = ();
-
- my @delegates;
- for my $method (@schema_methods) {
- push @delegates, $method unless exists $my_methods{$method};
- }
-
- return \@delegates;
-}
-
-sub _pass_options_to_schema {
- my ($self, $args) = @_;
-
- my @attributes = map {
- $_->init_arg || ()
- } $self->meta->get_all_attributes;
-
- my %attributes;
- @attributes{@attributes} = ();
-
- for my $opt (keys %$args) {
- if (not exists $attributes{$opt}) {
- next unless $self->schema->can($opt);
- $self->schema->$opt($args->{$opt});
- }
- }
-}
-
-sub _pass_options_to_resultset {
- my ($self, $source, $args) = @_;
-
- my @attributes = map {
- $_->init_arg || ()
- } $self->meta->get_all_attributes;
-
- my %attributes;
- @attributes{@attributes} = ();
-
- for my $opt (keys %$args) {
- if (not exists $attributes{$opt}) {
- my $rs_class = $self->schema->source($source)->resultset_class;
- next unless $rs_class->can($opt);
- $rs_class->$opt($args->{$opt});
- }
- }
-}
-
-=head1 SEE ALSO
-
-L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class::Schema>
-
-=head1 AUTHOR
-
-See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
-L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
-
-=head1 COPYRIGHT
-
-See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
-
-=head1 LICENSE
-
-This program is free software, you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-=cut
-
-1;
Copied: Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm (from rev 14009, Catalyst-Model-DBIC-Schema/trunk/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm)
===================================================================
--- Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm (rev 0)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/lib/Catalyst/TraitFor/Model/DBIC/Schema/SchemaProxy.pm 2011-05-11 06:06:03 UTC (rev 14011)
@@ -0,0 +1,195 @@
+package Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy;
+
+use namespace::autoclean;
+use Moose::Role;
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use Catalyst::Model::DBIC::Schema::Types 'Schema';
+
+=head1 NAME
+
+Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy - Proxy Schema Methods and
+Options from Model
+
+=head1 DESCRIPTION
+
+Allows you to call your L<DBIx::Class::Schema> methods directly on the Model
+instance, and passes config options to your L<DBIx::Class::Schema> and
+L<DBIx::Class::ResultSet> attributes at C<BUILD> time.
+
+Methods and attributes local to your C<Model> take precedence over
+L<DBIx::Class::Schema> or L<DBIx::Class::ResultSet> methods and attributes.
+
+=head1 CREATING SCHEMA CONFIG ATTRIBUTES
+
+To create attributes in your C<Schema.pm>, use either Moose or
+L<Class::Accessor::Grouped>, which is inherited from by all L<DBIx::Class>
+classes automatically. E.g.:
+
+ __PACKAGE__->mk_group_accessors(simple => qw/
+ config_key1
+ config_key2
+ ...
+ /);
+
+Or with L<Moose>:
+
+ use Moose;
+ has config_key1 => (is => 'rw', default => 'default_value');
+
+This code can be added after the md5sum on L<DBIx::Class::Schema::Loader>
+generated schemas.
+
+At app startup, any non-local options will be passed to these accessors, and can
+be accessed as usual via C<< $schema->config_key1 >>.
+
+These config values go into your C<Model::DB> block, along with normal config
+values.
+
+=head1 CREATING RESULTSET CONFIG ATTRIBUTES
+
+You can create classdata on L<DBIx::Class::ResultSet> classes to hold values
+from L<Catalyst> config.
+
+The code for this looks something like this:
+
+ package MySchema::ResultSet::Foo;
+
+ use base 'DBIx::Class::ResultSet';
+
+ __PACKAGE__->mk_group_accessors(inherited => qw/
+ rs_config_key1
+ rs_config_key2
+ ...
+ /);
+ __PACKAGE__->rs_config_key1('default_value');
+
+Or, if you prefer L<Moose>:
+
+ package MySchema::ResultSet::Foo;
+
+ use Moose;
+ use MooseX::NonMoose;
+ use MooseX::ClassAttribute;
+ extends 'DBIx::Class::ResultSet';
+
+ class_has rs_config_key1 => (is => 'rw', default => 'default_value');
+
+In your catalyst config, use the generated Model name as the config key, e.g.:
+
+ <Model::DB::Users>
+ strict_passwords 1
+ </Model::DB::Users>
+
+=cut
+
+after setup => sub {
+ my ($self, $args) = @_;
+
+ my $schema = $self->schema;
+
+ my $was_mutable = $self->meta->is_mutable;
+
+ $self->meta->make_mutable;
+ $self->meta->add_attribute('schema',
+ is => 'rw',
+ isa => Schema,
+ handles => $self->_delegates # this removes the attribute too
+ );
+ $self->meta->make_immutable unless $was_mutable;
+
+ $self->schema($schema) if $schema;
+};
+
+after BUILD => sub {
+ my ($self, $args) = @_;
+
+ $self->_pass_options_to_schema($args);
+
+ for my $source ($self->schema->sources) {
+ my $config_key = 'Model::' . $self->model_name . '::' . $source;
+ my $config = $self->app_class->config->{$config_key};
+ next unless $config;
+ $self->_pass_options_to_resultset($source, $config);
+ }
+};
+
+sub _delegates {
+ my $self = shift;
+
+ my $schema_meta = Class::MOP::Class->initialize($self->schema_class);
+ my @schema_methods = $schema_meta->get_all_method_names;
+
+# combine with any already added by other schemas
+ my @handles = eval {
+ @{ $self->meta->find_attribute_by_name('schema')->handles }
+ };
+
+# now kill the attribute, otherwise add_attribute in BUILD will not do the right
+# thing (it clears the handles for some reason.) May be a Moose bug.
+ eval { $self->meta->remove_attribute('schema') };
+
+ my %schema_methods;
+ @schema_methods{ @schema_methods, @handles } = ();
+ @schema_methods = keys %schema_methods;
+
+ my @my_methods = $self->meta->get_all_method_names;
+ my %my_methods;
+ @my_methods{@my_methods} = ();
+
+ my @delegates;
+ for my $method (@schema_methods) {
+ push @delegates, $method unless exists $my_methods{$method};
+ }
+
+ return \@delegates;
+}
+
+sub _pass_options_to_schema {
+ my ($self, $args) = @_;
+
+ my @attributes = map {
+ $_->init_arg || ()
+ } $self->meta->get_all_attributes;
+
+ my %attributes;
+ @attributes{@attributes} = ();
+
+ for my $opt (keys %$args) {
+ if (not exists $attributes{$opt}) {
+ next unless $self->schema->can($opt);
+ $self->schema->$opt($args->{$opt});
+ }
+ }
+}
+
+sub _pass_options_to_resultset {
+ my ($self, $source, $args) = @_;
+
+ for my $opt (keys %$args) {
+ my $rs_class = $self->schema->source($source)->resultset_class;
+ next unless $rs_class->can($opt);
+ $rs_class->$opt($args->{$opt});
+ }
+}
+
+=head1 SEE ALSO
+
+L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class::Schema>
+
+=head1 AUTHOR
+
+See L<Catalyst::Model::DBIC::Schema/AUTHOR> and
+L<Catalyst::Model::DBIC::Schema/CONTRIBUTORS>.
+
+=head1 COPYRIGHT
+
+See L<Catalyst::Model::DBIC::Schema/COPYRIGHT>.
+
+=head1 LICENSE
+
+This program is free software, you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
Deleted: Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t
===================================================================
--- Catalyst-Model-DBIC-Schema/trunk/t/08helper.t 2011-04-29 12:50:12 UTC (rev 14007)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t 2011-05-11 06:06:03 UTC (rev 14011)
@@ -1,177 +0,0 @@
-use strict;
-use warnings;
-
-use FindBin '$Bin';
-use lib "$Bin/lib";
-
-use Test::More;
-use Test::Exception;
-use Catalyst::Helper::Model::DBIC::Schema;
-use Storable 'dclone';
-eval "use Catalyst::Helper";
-plan skip_all => 'Catalyst::Helper required for tests' if $@;
-
-my $helper = Catalyst::Helper->new;
-$helper->{base} = $Bin;
-my $static = 'create=static';
-my $dynamic = 'create=dynamic';
-my $sqlite = 'dbi:SQLite:myapp.db';
-my $pg = 'dbi:Pg:dbname=foo';
-my $on_connect_do = 'on_connect_do=["select 1", "select 2"]';
-my $quote_char = 'quote_char="';
-my $name_sep = 'name_sep=.';
-my $i;
-
-$i = instance(schema_class => 'ASchemaClass');
-is $i->old_schema, 1, '->load_classes detected correctly';
-
-throws_ok { $i = instance(args => [$static, 'DbI:SQLite:myapp.db']) }
- qr/case matters/i, "wrong case for 'dbi:' DSN part";
-
-$i = instance(args => ['traits=Caching']);
-is_deeply $i->traits, ['Caching'], 'one trait';
-is $i->helper->{traits}, "['Caching']", 'one trait as string';
-
-$i = instance(args => ['traits=Caching,Replicated']);
-is_deeply $i->traits, ['Caching', 'Replicated'], 'two traits';
-is $i->helper->{traits}, "['Caching','Replicated']", 'two traits as string';
-
-$i = instance(args => [$static]);
-is $i->create, 'static', 'create=static';
-
-$i = instance(args => [$static,
- q{moniker_map={ authors => "AUTHORS", books => "BOOKS" }}]
-);
-is_deeply $i->loader_args->{moniker_map},
- { authors => 'AUTHORS', books => 'BOOKS' },
- 'loader hash arg';
-is $i->helper->{loader_args}{moniker_map},
- q{{authors => "AUTHORS",books => "BOOKS"}},
- 'loader hash arg as string';
-
-$i = instance(args => [$static, q{foo=["bar","baz"]}]);
-is_deeply $i->loader_args->{foo}, ['bar', 'baz'], 'loader array arg';
-is $i->helper->{loader_args}{foo},
- q{["bar","baz"]},
- 'loader array arg as string';
-
-$i = instance(args => [$static, q{components=TimeStamp}]);
-is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp'],
- 'extra component';
-is $i->helper->{loader_args}{components},
- q{["InflateColumn::DateTime","TimeStamp"]},
- 'components as string';
-
-$i = instance(
- schema_class => 'ASchemaClass',
- args => [$static, q{components=TimeStamp}]
-);
-is_deeply $i->components, ['TimeStamp'],
- 'extra component with ->load_classes';
-
-$i = instance(args => [$static, q{components=TimeStamp,Foo}]);
-is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp', 'Foo'],
- 'two extra components';
-
-$i = instance(args => [$static, q{constraint=^(foo|bar)$}]);
-is $i->loader_args->{constraint}, qr/^(foo|bar)$/,
- 'constraint loader arg';
-is $i->helper->{loader_args}{constraint},
- q{qr/(?-xism:^(foo|bar)$)/},
- 'constraint loader arg as string';
-
-$i = instance(args => [$static, q{exclude=^(foo|bar)$}]);
-is $i->loader_args->{exclude}, qr/^(foo|bar)$/,
- 'exclude loader arg';
-
-$i = instance(args => [$static, q{db_schema=foo;bar::baz/quux}]);
-is $i->loader_args->{db_schema}, q{foo;bar::baz/quux},
- 'simple value loader arg';
-
-$i = instance(args => [
- $static, 'components=TimeStamp', $sqlite, $on_connect_do,
- $quote_char, $name_sep
-]);
-
-is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp'],
- 'extra component';
-
-is $i->connect_info->{dsn}, $sqlite, 'connect_info dsn';
-is $i->connect_info->{user}, '', 'sqlite omitted user';
-is $i->connect_info->{password}, '', 'sqlite omitted password';
-
-is_deeply $i->connect_info->{on_connect_do},
- ['select 1', 'select 2'], 'connect_info data struct';
-
-is $i->helper->{connect_info}{on_connect_do},
- q{["select 1", "select 2"]}, 'connect_info data struct as string';
-
-is $i->connect_info->{quote_char}, '"', 'connect_info quote_char';
-
-is $i->helper->{connect_info}{quote_char}, 'q{"}',
- 'connect_info quote_char as string';
-
-is $i->connect_info->{name_sep}, '.', 'connect_info name_sep';
-
-is $i->helper->{connect_info}{name_sep}, 'q{.}',
- 'connect_info name_sep as string';
-
-$i = instance(args => [
- $static, $sqlite, 'on_connect_do=PRAGMA foreign_keys = ON'
-]);
-
-is $i->connect_info->{on_connect_do},
- 'PRAGMA foreign_keys = ON', 'on_connect_do string';
-
-is $i->helper->{connect_info}{on_connect_do},
- 'q{PRAGMA foreign_keys = ON}', 'on_connect_do string as string';
-
-$i = instance(args => [
- $static, 'components=TimeStamp', $sqlite, '', $on_connect_do,
- $quote_char, $name_sep
-]);
-
-is $i->connect_info->{dsn}, $sqlite, 'connect_info dsn';
-is $i->connect_info->{user}, '', 'sqlite user';
-is $i->connect_info->{password}, '', 'sqlite omitted password';
-
-$i = instance(args => [
- $static, 'components=TimeStamp', $pg, 'user', 'pass', $on_connect_do,
- $quote_char, $name_sep
-]);
-
-is $i->connect_info->{dsn}, $pg, 'connect_info dsn';
-is $i->connect_info->{user}, 'user', 'user';
-is $i->connect_info->{password}, 'pass', 'password';
-
-$i = instance(args => [
- $static, $pg, 'user', 'pass', 'quote_char=[]', $name_sep
-]);
-
-is_deeply $i->connect_info->{quote_char}, ['[', ']'],
- '2 character quote_char';
-is $i->helper->{connect_info}{quote_char}, '["[","]"]',
- '2 character quote_char as string';
-
-$i = instance(args => [
- $static, 'components=TimeStamp', $sqlite, $on_connect_do,
- $quote_char, $name_sep, '{ auto_savepoint => 1, AutoCommit => 0 }'
-]);
-
-is $i->connect_info->{auto_savepoint}, 1, 'connect_info arg from extra hash';
-is $i->connect_info->{AutoCommit}, 0, 'connect_info arg from extra hash';
-is $i->helper->{connect_info}{auto_savepoint}, 'q{1}',
- 'connect_info arg from extra hash as string';
-is $i->helper->{connect_info}{AutoCommit}, 'q{0}',
- 'connect_info arg from extra hash as string';
-
-done_testing;
-
-sub instance {
- Catalyst::Helper::Model::DBIC::Schema->new(
- schema_class => 'AnotherSchemaClass',
- helper => dclone($helper),
- args => ['create=static'],
- @_
- )
-}
Copied: Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t (from rev 14008, Catalyst-Model-DBIC-Schema/trunk/t/08helper.t)
===================================================================
--- Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t (rev 0)
+++ Catalyst-Model-DBIC-Schema/tags/0.49/t/08helper.t 2011-05-11 06:06:03 UTC (rev 14011)
@@ -0,0 +1,178 @@
+use strict;
+use warnings;
+
+use FindBin '$Bin';
+use lib "$Bin/lib";
+
+use Test::More;
+use Test::Exception;
+use Catalyst::Helper::Model::DBIC::Schema;
+use Storable 'dclone';
+eval "use Catalyst::Helper";
+plan skip_all => 'Catalyst::Helper required for tests' if $@;
+
+my $helper = Catalyst::Helper->new;
+$helper->{base} = $Bin;
+my $static = 'create=static';
+my $dynamic = 'create=dynamic';
+my $sqlite = 'dbi:SQLite:myapp.db';
+my $pg = 'dbi:Pg:dbname=foo';
+my $on_connect_do = 'on_connect_do=["select 1", "select 2"]';
+my $quote_char = 'quote_char="';
+my $name_sep = 'name_sep=.';
+my $i;
+
+$i = instance(schema_class => 'ASchemaClass');
+is $i->old_schema, 1, '->load_classes detected correctly';
+
+throws_ok { $i = instance(args => [$static, 'DbI:SQLite:myapp.db']) }
+ qr/case matters/i, "wrong case for 'dbi:' DSN part";
+
+$i = instance(args => ['traits=Caching']);
+is_deeply $i->traits, ['Caching'], 'one trait';
+is $i->helper->{traits}, "['Caching']", 'one trait as string';
+
+$i = instance(args => ['traits=Caching,Replicated']);
+is_deeply $i->traits, ['Caching', 'Replicated'], 'two traits';
+is $i->helper->{traits}, "['Caching','Replicated']", 'two traits as string';
+
+$i = instance(args => [$static]);
+is $i->create, 'static', 'create=static';
+
+$i = instance(args => [$static,
+ q{moniker_map={ authors => "AUTHORS", books => "BOOKS" }}]
+);
+is_deeply $i->loader_args->{moniker_map},
+ { authors => 'AUTHORS', books => 'BOOKS' },
+ 'loader hash arg';
+is $i->helper->{loader_args}{moniker_map},
+ q{{authors => "AUTHORS",books => "BOOKS"}},
+ 'loader hash arg as string';
+
+$i = instance(args => [$static, q{foo=["bar","baz"]}]);
+is_deeply $i->loader_args->{foo}, ['bar', 'baz'], 'loader array arg';
+is $i->helper->{loader_args}{foo},
+ q{["bar","baz"]},
+ 'loader array arg as string';
+
+$i = instance(args => [$static, q{components=TimeStamp}]);
+is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp'],
+ 'extra component';
+is $i->helper->{loader_args}{components},
+ q{["InflateColumn::DateTime","TimeStamp"]},
+ 'components as string';
+
+$i = instance(
+ schema_class => 'ASchemaClass',
+ args => [$static, q{components=TimeStamp}]
+);
+is_deeply $i->components, ['TimeStamp'],
+ 'extra component with ->load_classes';
+
+$i = instance(args => [$static, q{components=TimeStamp,Foo}]);
+is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp', 'Foo'],
+ 'two extra components';
+
+my $flags = qr// =~ /\^/ ? '^' : "-xism";
+$i = instance(args => [$static, q{constraint=^(foo|bar)$}]);
+is $i->loader_args->{constraint}, qr/^(foo|bar)$/,
+ 'constraint loader arg';
+is $i->helper->{loader_args}{constraint},
+ qq{qr/(?$flags:^(foo|bar)\$)/},
+ 'constraint loader arg as string';
+
+$i = instance(args => [$static, q{exclude=^(foo|bar)$}]);
+is $i->loader_args->{exclude}, qr/^(foo|bar)$/,
+ 'exclude loader arg';
+
+$i = instance(args => [$static, q{db_schema=foo;bar::baz/quux}]);
+is $i->loader_args->{db_schema}, q{foo;bar::baz/quux},
+ 'simple value loader arg';
+
+$i = instance(args => [
+ $static, 'components=TimeStamp', $sqlite, $on_connect_do,
+ $quote_char, $name_sep
+]);
+
+is_deeply $i->components, ['InflateColumn::DateTime', 'TimeStamp'],
+ 'extra component';
+
+is $i->connect_info->{dsn}, $sqlite, 'connect_info dsn';
+is $i->connect_info->{user}, '', 'sqlite omitted user';
+is $i->connect_info->{password}, '', 'sqlite omitted password';
+
+is_deeply $i->connect_info->{on_connect_do},
+ ['select 1', 'select 2'], 'connect_info data struct';
+
+is $i->helper->{connect_info}{on_connect_do},
+ q{["select 1", "select 2"]}, 'connect_info data struct as string';
+
+is $i->connect_info->{quote_char}, '"', 'connect_info quote_char';
+
+is $i->helper->{connect_info}{quote_char}, 'q{"}',
+ 'connect_info quote_char as string';
+
+is $i->connect_info->{name_sep}, '.', 'connect_info name_sep';
+
+is $i->helper->{connect_info}{name_sep}, 'q{.}',
+ 'connect_info name_sep as string';
+
+$i = instance(args => [
+ $static, $sqlite, 'on_connect_do=PRAGMA foreign_keys = ON'
+]);
+
+is $i->connect_info->{on_connect_do},
+ 'PRAGMA foreign_keys = ON', 'on_connect_do string';
+
+is $i->helper->{connect_info}{on_connect_do},
+ 'q{PRAGMA foreign_keys = ON}', 'on_connect_do string as string';
+
+$i = instance(args => [
+ $static, 'components=TimeStamp', $sqlite, '', $on_connect_do,
+ $quote_char, $name_sep
+]);
+
+is $i->connect_info->{dsn}, $sqlite, 'connect_info dsn';
+is $i->connect_info->{user}, '', 'sqlite user';
+is $i->connect_info->{password}, '', 'sqlite omitted password';
+
+$i = instance(args => [
+ $static, 'components=TimeStamp', $pg, 'user', 'pass', $on_connect_do,
+ $quote_char, $name_sep
+]);
+
+is $i->connect_info->{dsn}, $pg, 'connect_info dsn';
+is $i->connect_info->{user}, 'user', 'user';
+is $i->connect_info->{password}, 'pass', 'password';
+
+$i = instance(args => [
+ $static, $pg, 'user', 'pass', 'quote_char=[]', $name_sep
+]);
+
+is_deeply $i->connect_info->{quote_char}, ['[', ']'],
+ '2 character quote_char';
+is $i->helper->{connect_info}{quote_char}, '["[","]"]',
+ '2 character quote_char as string';
+
+$i = instance(args => [
+ $static, 'components=TimeStamp', $sqlite, $on_connect_do,
+ $quote_char, $name_sep, '{ auto_savepoint => 1, AutoCommit => 0 }'
+]);
+
+is $i->connect_info->{auto_savepoint}, 1, 'connect_info arg from extra hash';
+is $i->connect_info->{AutoCommit}, 0, 'connect_info arg from extra hash';
+is $i->helper->{connect_info}{auto_savepoint}, 'q{1}',
+ 'connect_info arg from extra hash as string';
+is $i->helper->{connect_info}{AutoCommit}, 'q{0}',
+ 'connect_info arg from extra hash as string';
+
+done_testing;
+
+sub instance {
+ Catalyst::Helper::Model::DBIC::Schema->new(
+ schema_class => 'AnotherSchemaClass',
+ helper => dclone($helper),
+ args => ['create=static'],
+ @_
+ )
+}
More information about the Catalyst-commits
mailing list