[Catalyst-commits] r10999 - / trunk trunk/Catalyst-Model-DBIC-Schema
trunk/Catalyst-Model-DBIC-Schema/lib
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema
trunk/Catalyst-Model-DBIC-Schema/t
trunk/Catalyst-Model-DBIC-Schema/t/lib
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Wed Jul 29 21:54:13 GMT 2009
Author: t0m
Date: 2009-07-29 21:54:10 +0000 (Wed, 29 Jul 2009)
New Revision: 10999
Added:
trunk/Catalyst-Model-DBIC-Schema/
trunk/Catalyst-Model-DBIC-Schema/Changes
trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP
trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
trunk/Catalyst-Model-DBIC-Schema/TODO
trunk/Catalyst-Model-DBIC-Schema/lib/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm
trunk/Catalyst-Model-DBIC-Schema/t/
trunk/Catalyst-Model-DBIC-Schema/t/01use.t
trunk/Catalyst-Model-DBIC-Schema/t/02pod.t
trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t
trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t
trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t
trunk/Catalyst-Model-DBIC-Schema/t/08helper.t
trunk/Catalyst-Model-DBIC-Schema/t/lib/
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm
Removed:
Catalyst-Model-DBIC-Schema/
trunk/Catalyst-Model-DBIC-Schema/Changes
trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP
trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
trunk/Catalyst-Model-DBIC-Schema/TODO
trunk/Catalyst-Model-DBIC-Schema/lib/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm
trunk/Catalyst-Model-DBIC-Schema/t/
trunk/Catalyst-Model-DBIC-Schema/t/01use.t
trunk/Catalyst-Model-DBIC-Schema/t/02pod.t
trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t
trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t
trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t
trunk/Catalyst-Model-DBIC-Schema/t/08helper.t
trunk/Catalyst-Model-DBIC-Schema/t/lib/
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/
trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/
trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/
trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm
Log:
Un fuck by reverse merge acrosss the entire repos - svn merge -r 10977:10972 .
Copied: trunk/Catalyst-Model-DBIC-Schema (from rev 10972, trunk/Catalyst-Model-DBIC-Schema)
Deleted: trunk/Catalyst-Model-DBIC-Schema/Changes
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Changes 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/Changes 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,115 +0,0 @@
-Revision history for Perl extension Catalyst::Model::DBIC::Schema
-
-0.26 As yet unreleased
- - fix loading connect_info from schema-defined connection (RT 48084)
- - Fix missing dep on Catalyst::Helper that made tests fail (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: trunk/Catalyst-Model-DBIC-Schema/Changes (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/Changes)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Changes (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/Changes 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,115 @@
+Revision history for Perl extension Catalyst::Model::DBIC::Schema
+
+0.26 As yet unreleased
+ - fix loading connect_info from schema-defined connection (RT 48084)
+ - Fix missing dep on Catalyst::Helper that made tests fail (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: trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,28 +0,0 @@
-# Avoid version control files.
-\bRCS\b
-\bCVS\b
-,v$
-\B\.svn\b
-
-# Avoid Makemaker generated and utility files.
-\bMakefile$
-\bblib
-\bMakeMaker-\d
-\bpm_to_blib$
-\bblibdirs$
-^MANIFEST\.SKIP$
-
-# Avoid Module::Build generated and utility files.
-\bBuild$
-\b_build
-
-# Avoid temp and backup files.
-~$
-\.tmp$
-\.old$
-\.bak$
-\#$
-\b\.#
-
-# avoid dist files
-\.tar\.gz$
Copied: trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/MANIFEST.SKIP 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,28 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\b\.#
+
+# avoid dist files
+\.tar\.gz$
Deleted: trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,42 +0,0 @@
-use inc::Module::Install 0.91;
-
-name 'Catalyst-Model-DBIC-Schema';
-all_from 'lib/Catalyst/Model/DBIC/Schema.pm';
-
-requires 'DBIx::Class' => '0.08107';
-requires 'Catalyst::Runtime' => '5.80005';
-requires 'CatalystX::Component::Traits' => '0.03';
-requires 'Moose';
-requires 'Moose::Autobox';
-requires 'MooseX::Types';
-requires 'namespace::autoclean';
-requires 'Carp::Clan';
-requires 'List::MoreUtils';
-requires 'Tie::IxHash';
-
-test_requires 'Test::More';
-test_requires 'Test::Exception';
-
-feature 'Catalyst::Helper support',
- -default => 0,
- 'Catalyst::Devel' => '1.0',
- 'DBIx::Class::Schema::Loader' => '0.04005';
-
-feature 'Caching support',
- -default => 0,
- 'DBIx::Class::Cursor::Cached' => 0;
-
-feature 'Replication support',
- -default => 0,
- 'MooseX::AttributeHelpers' => 0,
- 'Hash::Merge' => 0;
-
-if(-e 'MANIFEST.SKIP') {
- system("pod2text lib/Catalyst/Model/DBIC/Schema.pm > README");
-}
-
-auto_provides;
-auto_install;
-resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Model-DBIC-Schema/';
-
-WriteAll;
Copied: trunk/Catalyst-Model-DBIC-Schema/Makefile.PL (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/Makefile.PL)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Makefile.PL (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,42 @@
+use inc::Module::Install 0.91;
+
+name 'Catalyst-Model-DBIC-Schema';
+all_from 'lib/Catalyst/Model/DBIC/Schema.pm';
+
+requires 'DBIx::Class' => '0.08107';
+requires 'Catalyst::Runtime' => '5.80005';
+requires 'CatalystX::Component::Traits' => '0.03';
+requires 'Moose';
+requires 'Moose::Autobox';
+requires 'MooseX::Types';
+requires 'namespace::autoclean';
+requires 'Carp::Clan';
+requires 'List::MoreUtils';
+requires 'Tie::IxHash';
+
+test_requires 'Test::More';
+test_requires 'Test::Exception';
+
+feature 'Catalyst::Helper support',
+ -default => 0,
+ 'Catalyst::Devel' => '1.0',
+ 'DBIx::Class::Schema::Loader' => '0.04005';
+
+feature 'Caching support',
+ -default => 0,
+ 'DBIx::Class::Cursor::Cached' => 0;
+
+feature 'Replication support',
+ -default => 0,
+ 'MooseX::AttributeHelpers' => 0,
+ 'Hash::Merge' => 0;
+
+if(-e 'MANIFEST.SKIP') {
+ system("pod2text lib/Catalyst/Model/DBIC/Schema.pm > README");
+}
+
+auto_provides;
+auto_install;
+resources repository => 'http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Model-DBIC-Schema/';
+
+WriteAll;
Deleted: trunk/Catalyst-Model-DBIC-Schema/TODO
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/TODO 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/TODO 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,3 +0,0 @@
-timezone and locale support for dates at helper time
-
-see why warnings get silenced (https://rt.cpan.org/Ticket/Display.html?id=47101)
Copied: trunk/Catalyst-Model-DBIC-Schema/TODO (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/TODO)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/TODO (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/TODO 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,3 @@
+timezone and locale support for dates at helper time
+
+see why warnings get silenced (https://rt.cpan.org/Ticket/Display.html?id=47101)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC)
Deleted: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,678 +0,0 @@
-package Catalyst::Helper::Model::DBIC::Schema;
-
-use namespace::autoclean;
-use Moose;
-no warnings 'uninitialized';
-
-our $VERSION = '0.25';
-
-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 Moose::Autobox;
-use List::MoreUtils 'firstidx';
-use Scalar::Util 'looks_like_number';
-
-=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
-
-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 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->flatten if $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{'$_'} } ($self->traits->flatten))
- .']';
-
- 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});
-
- $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,
- (%loader_args ? %loader_args : ()),
- (!$self->old_schema ? (
- use_namespaces => 1
- ) : ()),
- (@components ? (
- components => \@components
- ) : ())
- );
-
- $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) = @_;
-
- my @components = $self->old_schema ? () : ('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;
-
- my @schema_pm = split '::', $self->schema_class;
- $schema_pm[-1] .= '.pm';
- my $schema_file =
- File::Spec->catfile($self->helper->{base}, 'lib', @schema_pm);
-
- if (-f $schema_file) {
- my $schema_code = do { local (@ARGV, $/) = $schema_file; <> };
- return 1 if $schema_code =~ /->load_classes/;
- }
-
- 0;
-}
-
-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 _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 $code =~ m{^[\w;:/]*\z};
-
- 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');
-
- eval { Class::MOP::load_class('DBIx::Class::Schema::Loader') };
- die "Cannot load DBIx::Class::Schema::Loader: $@" if $@;
-
- 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
-
-Brandon L Black, C<blblack at gmail.com>
-
-Contributors:
-
-Rafael Kitover, C<rkitover at cpan.org>
-
-=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: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,678 @@
+package Catalyst::Helper::Model::DBIC::Schema;
+
+use namespace::autoclean;
+use Moose;
+no warnings 'uninitialized';
+
+our $VERSION = '0.25';
+
+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 Moose::Autobox;
+use List::MoreUtils 'firstidx';
+use Scalar::Util 'looks_like_number';
+
+=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
+
+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 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->flatten if $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{'$_'} } ($self->traits->flatten))
+ .']';
+
+ 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});
+
+ $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,
+ (%loader_args ? %loader_args : ()),
+ (!$self->old_schema ? (
+ use_namespaces => 1
+ ) : ()),
+ (@components ? (
+ components => \@components
+ ) : ())
+ );
+
+ $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) = @_;
+
+ my @components = $self->old_schema ? () : ('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;
+
+ my @schema_pm = split '::', $self->schema_class;
+ $schema_pm[-1] .= '.pm';
+ my $schema_file =
+ File::Spec->catfile($self->helper->{base}, 'lib', @schema_pm);
+
+ if (-f $schema_file) {
+ my $schema_code = do { local (@ARGV, $/) = $schema_file; <> };
+ return 1 if $schema_code =~ /->load_classes/;
+ }
+
+ 0;
+}
+
+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 _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 $code =~ m{^[\w;:/]*\z};
+
+ 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');
+
+ eval { Class::MOP::load_class('DBIx::Class::Schema::Loader') };
+ die "Cannot load DBIx::Class::Schema::Loader: $@" if $@;
+
+ 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
+
+Brandon L Black, C<blblack at gmail.com>
+
+Contributors:
+
+Rafael Kitover, C<rkitover at cpan.org>
+
+=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: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema)
Deleted: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,101 +0,0 @@
-package # hide from PAUSE
- Catalyst::Model::DBIC::Schema::Types;
-
-use MooseX::Types -declare => [qw/
- ConnectInfo ConnectInfos Replicants LoadedClass CreateOption
-/];
-
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
-use MooseX::Types::Moose qw/ArrayRef HashRef Str ClassName/;
-use Scalar::Util 'reftype';
-use List::MoreUtils 'all';
-
-use namespace::clean -except => 'meta';
-
-class_type 'DBIx::Class::Schema';
-
-subtype LoadedClass,
- as ClassName;
-
-coerce LoadedClass,
- from Str,
- via { Class::MOP::load_class($_); $_ };
-
-subtype ConnectInfo,
- as HashRef,
- where { exists $_->{dsn} },
- message { 'Does not look like a valid connect_info' };
-
-coerce ConnectInfo,
- from Str,
- via(\&_coerce_connect_info_from_str),
- from ArrayRef,
- via(\&_coerce_connect_info_from_arrayref);
-
-# { connect_info => [ ... ] } coercion would be nice, but no chained coercions
-# yet.
-# Also no coercion from base type (yet,) but in Moose git already.
-# from HashRef,
-# via { $_->{connect_info} },
-
-subtype ConnectInfos,
- as ArrayRef[ConnectInfo],
- message { "Not a valid array of connect_info's" };
-
-coerce ConnectInfos,
- from Str,
- via { [ _coerce_connect_info_from_str() ] },
- from ArrayRef,
- via { [ map {
- !ref $_ ? _coerce_connect_info_from_str()
- : reftype $_ eq 'HASH' ? $_
- : reftype $_ eq 'ARRAY' ? _coerce_connect_info_from_arrayref()
- : die 'invalid connect_info'
- } @$_ ] };
-
-# Helper stuff
-
-subtype CreateOption,
- as Str,
- where { /^(?:static|dynamic)\z/ },
- message { "Invalid create option, must be one of 'static' or 'dynamic'" };
-
-sub _coerce_connect_info_from_arrayref {
- my %connect_info;
-
- # make a copy
- $_ = [ @$_ ];
-
- if (!ref $_->[0]) { # array style
- $connect_info{dsn} = shift @$_;
- $connect_info{user} = shift @$_ if !ref $_->[0];
- $connect_info{password} = shift @$_ if !ref $_->[0];
-
- for my $i (0..1) {
- my $extra = shift @$_;
- last unless $extra;
- die "invalid connect_info" unless reftype $extra eq 'HASH';
-
- %connect_info = (%connect_info, %$extra);
- }
-
- die "invalid connect_info" if @$_;
- } elsif (@$_ == 1 && reftype $_->[0] eq 'HASH') {
- return $_->[0];
- } else {
- die "invalid connect_info";
- }
-
- for my $key (qw/user password/) {
- $connect_info{$key} = ''
- if not defined $connect_info{$key};
- }
-
- \%connect_info;
-}
-
-sub _coerce_connect_info_from_str {
- +{ dsn => $_, user => '', password => '' }
-}
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Types.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,101 @@
+package # hide from PAUSE
+ Catalyst::Model::DBIC::Schema::Types;
+
+use MooseX::Types -declare => [qw/
+ ConnectInfo ConnectInfos Replicants LoadedClass CreateOption
+/];
+
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use MooseX::Types::Moose qw/ArrayRef HashRef Str ClassName/;
+use Scalar::Util 'reftype';
+use List::MoreUtils 'all';
+
+use namespace::clean -except => 'meta';
+
+class_type 'DBIx::Class::Schema';
+
+subtype LoadedClass,
+ as ClassName;
+
+coerce LoadedClass,
+ from Str,
+ via { Class::MOP::load_class($_); $_ };
+
+subtype ConnectInfo,
+ as HashRef,
+ where { exists $_->{dsn} },
+ message { 'Does not look like a valid connect_info' };
+
+coerce ConnectInfo,
+ from Str,
+ via(\&_coerce_connect_info_from_str),
+ from ArrayRef,
+ via(\&_coerce_connect_info_from_arrayref);
+
+# { connect_info => [ ... ] } coercion would be nice, but no chained coercions
+# yet.
+# Also no coercion from base type (yet,) but in Moose git already.
+# from HashRef,
+# via { $_->{connect_info} },
+
+subtype ConnectInfos,
+ as ArrayRef[ConnectInfo],
+ message { "Not a valid array of connect_info's" };
+
+coerce ConnectInfos,
+ from Str,
+ via { [ _coerce_connect_info_from_str() ] },
+ from ArrayRef,
+ via { [ map {
+ !ref $_ ? _coerce_connect_info_from_str()
+ : reftype $_ eq 'HASH' ? $_
+ : reftype $_ eq 'ARRAY' ? _coerce_connect_info_from_arrayref()
+ : die 'invalid connect_info'
+ } @$_ ] };
+
+# Helper stuff
+
+subtype CreateOption,
+ as Str,
+ where { /^(?:static|dynamic)\z/ },
+ message { "Invalid create option, must be one of 'static' or 'dynamic'" };
+
+sub _coerce_connect_info_from_arrayref {
+ my %connect_info;
+
+ # make a copy
+ $_ = [ @$_ ];
+
+ if (!ref $_->[0]) { # array style
+ $connect_info{dsn} = shift @$_;
+ $connect_info{user} = shift @$_ if !ref $_->[0];
+ $connect_info{password} = shift @$_ if !ref $_->[0];
+
+ for my $i (0..1) {
+ my $extra = shift @$_;
+ last unless $extra;
+ die "invalid connect_info" unless reftype $extra eq 'HASH';
+
+ %connect_info = (%connect_info, %$extra);
+ }
+
+ die "invalid connect_info" if @$_;
+ } elsif (@$_ == 1 && reftype $_->[0] eq 'HASH') {
+ return $_->[0];
+ } else {
+ die "invalid connect_info";
+ }
+
+ for my $key (qw/user password/) {
+ $connect_info{$key} = ''
+ if not defined $connect_info{$key};
+ }
+
+ \%connect_info;
+}
+
+sub _coerce_connect_info_from_str {
+ +{ dsn => $_, user => '', password => '' }
+}
+
+1;
Deleted: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,612 +0,0 @@
-package Catalyst::Model::DBIC::Schema;
-
-use Moose;
-use mro 'c3';
-extends 'Catalyst::Model';
-with 'CatalystX::Component::Traits';
-
-our $VERSION = '0.25';
-
-use namespace::autoclean;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
-use Data::Dumper;
-use DBIx::Class ();
-use Moose::Autobox;
-
-use Catalyst::Model::DBIC::Schema::Types
- qw/ConnectInfo LoadedClass/;
-
-use MooseX::Types::Moose qw/ArrayRef Str ClassName Undef/;
-
-=head1 NAME
-
-Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
-
-=head1 SYNOPSIS
-
-Manual creation of a DBIx::Class::Schema and a Catalyst::Model::DBIC::Schema:
-
-=over
-
-=item 1.
-
-Create the DBIx:Class schema in MyApp/Schema/FilmDB.pm:
-
- package MyApp::Schema::FilmDB;
- use base qw/DBIx::Class::Schema/;
-
- __PACKAGE__->load_classes(qw/Actor Role/);
-
-=item 2.
-
-Create some classes for the tables in the database, for example an
-Actor in MyApp/Schema/FilmDB/Actor.pm:
-
- package MyApp::Schema::FilmDB::Actor;
- use base qw/DBIx::Class/
-
- __PACKAGE__->load_components(qw/Core/);
- __PACKAGE__->table('actor');
-
- ...
-
-and a Role in MyApp/Schema/FilmDB/Role.pm:
-
- package MyApp::Schema::FilmDB::Role;
- use base qw/DBIx::Class/
-
- __PACKAGE__->load_components(qw/Core/);
- __PACKAGE__->table('role');
-
- ...
-
-Notice that the schema is in MyApp::Schema, not in MyApp::Model. This way it's
-usable as a standalone module and you can test/run it without Catalyst.
-
-=item 3.
-
-To expose it to Catalyst as a model, you should create a DBIC Model in
-MyApp/Model/FilmDB.pm:
-
- package MyApp::Model::FilmDB;
- use base qw/Catalyst::Model::DBIC::Schema/;
-
- __PACKAGE__->config(
- schema_class => 'MyApp::Schema::FilmDB',
- connect_info => {
- dsn => "DBI:...",
- user => "username",
- password => "password",
- }
- );
-
-See below for a full list of the possible config parameters.
-
-=back
-
-Now you have a working Model which accesses your separate DBIC Schema. This can
-be used/accessed in the normal Catalyst manner, via $c->model():
-
- my $actor = $c->model('FilmDB::Actor')->find(1);
-
-You can also use it to set up DBIC authentication with
-L<Catalyst::Authentication::Store::DBIx::Class> in MyApp.pm:
-
- package MyApp;
-
- use Catalyst qw/... Authentication .../;
-
- ...
-
- __PACKAGE__->config->{authentication} =
- {
- default_realm => 'members',
- realms => {
- 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',
- }
- }
- }
- };
-
-C<< $c->model('Schema::Source') >> returns a L<DBIx::Class::ResultSet> for
-the source name parameter passed. To find out more about which methods can
-be called on a ResultSet, or how to add your own methods to it, please see
-the ResultSet documentation in the L<DBIx::Class> distribution.
-
-Some examples are given below:
-
- # 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(...);
-
-=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. See L<DBIx::Class::Manual::Cookbook/"Predefined searches">
-for more info.
-
-=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>
- </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
- connect_info:
- dsn: dbi:Oracle:mydb
- user: mtfnpy
- password: mypass
- LongReadLen: 1000000
- LongTruncOk: 1
- on_connect_do: [ "alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'" ]
- cursor_class: 'DBIx::Class::Cursor::Cached'
- 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>
-
-=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 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 storage
-
-Provides an accessor for the connected schema's storage object.
-Used often for debugging and controlling transactions.
-
-=cut
-
-has schema => (is => 'rw', isa => 'DBIx::Class::Schema');
-
-has schema_class => (
- is => 'ro',
- isa => LoadedClass,
- 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
-);
-
-sub BUILD {
- my $self = shift;
- 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($self);
- }
- }
-
- 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;
-
- $self->composed_schema($schema_class->compose_namespace($class));
-
- $self->schema($self->composed_schema->clone);
-
- $self->schema->storage_type($self->storage_type)
- if $self->storage_type;
-
- $self->schema->connection($self->connect_info);
-
- $self->_install_rs_models;
-}
-
-sub clone { shift->composed_schema->clone(@_); }
-
-sub connect { shift->composed_schema->connect(@_); }
-
-sub storage { shift->schema->storage(@_); }
-
-sub resultset { shift->schema->resultset(@_); }
-
-=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 => >>.
-
-=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;
-
- die "No sources found (did you forget to define your tables?)"
- unless @sources;
-
- 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 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<MooseX::Object::Pluggable>
-
-Traits:
-
-L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>,
-L<Catalyst::TraitFor::Model::DBIC::Schema::Replicated>
-
-=head1 AUTHOR
-
-Brandon L Black, C<blblack at gmail.com>
-
-Contributors:
-
-Rafael Kitover, C<rkitover at cpan.org>
-
-=head1 COPYRIGHT
-
-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:
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,612 @@
+package Catalyst::Model::DBIC::Schema;
+
+use Moose;
+use mro 'c3';
+extends 'Catalyst::Model';
+with 'CatalystX::Component::Traits';
+
+our $VERSION = '0.25';
+
+use namespace::autoclean;
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use Data::Dumper;
+use DBIx::Class ();
+use Moose::Autobox;
+
+use Catalyst::Model::DBIC::Schema::Types
+ qw/ConnectInfo LoadedClass/;
+
+use MooseX::Types::Moose qw/ArrayRef Str ClassName Undef/;
+
+=head1 NAME
+
+Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
+
+=head1 SYNOPSIS
+
+Manual creation of a DBIx::Class::Schema and a Catalyst::Model::DBIC::Schema:
+
+=over
+
+=item 1.
+
+Create the DBIx:Class schema in MyApp/Schema/FilmDB.pm:
+
+ package MyApp::Schema::FilmDB;
+ use base qw/DBIx::Class::Schema/;
+
+ __PACKAGE__->load_classes(qw/Actor Role/);
+
+=item 2.
+
+Create some classes for the tables in the database, for example an
+Actor in MyApp/Schema/FilmDB/Actor.pm:
+
+ package MyApp::Schema::FilmDB::Actor;
+ use base qw/DBIx::Class/
+
+ __PACKAGE__->load_components(qw/Core/);
+ __PACKAGE__->table('actor');
+
+ ...
+
+and a Role in MyApp/Schema/FilmDB/Role.pm:
+
+ package MyApp::Schema::FilmDB::Role;
+ use base qw/DBIx::Class/
+
+ __PACKAGE__->load_components(qw/Core/);
+ __PACKAGE__->table('role');
+
+ ...
+
+Notice that the schema is in MyApp::Schema, not in MyApp::Model. This way it's
+usable as a standalone module and you can test/run it without Catalyst.
+
+=item 3.
+
+To expose it to Catalyst as a model, you should create a DBIC Model in
+MyApp/Model/FilmDB.pm:
+
+ package MyApp::Model::FilmDB;
+ use base qw/Catalyst::Model::DBIC::Schema/;
+
+ __PACKAGE__->config(
+ schema_class => 'MyApp::Schema::FilmDB',
+ connect_info => {
+ dsn => "DBI:...",
+ user => "username",
+ password => "password",
+ }
+ );
+
+See below for a full list of the possible config parameters.
+
+=back
+
+Now you have a working Model which accesses your separate DBIC Schema. This can
+be used/accessed in the normal Catalyst manner, via $c->model():
+
+ my $actor = $c->model('FilmDB::Actor')->find(1);
+
+You can also use it to set up DBIC authentication with
+L<Catalyst::Authentication::Store::DBIx::Class> in MyApp.pm:
+
+ package MyApp;
+
+ use Catalyst qw/... Authentication .../;
+
+ ...
+
+ __PACKAGE__->config->{authentication} =
+ {
+ default_realm => 'members',
+ realms => {
+ 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',
+ }
+ }
+ }
+ };
+
+C<< $c->model('Schema::Source') >> returns a L<DBIx::Class::ResultSet> for
+the source name parameter passed. To find out more about which methods can
+be called on a ResultSet, or how to add your own methods to it, please see
+the ResultSet documentation in the L<DBIx::Class> distribution.
+
+Some examples are given below:
+
+ # 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(...);
+
+=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. See L<DBIx::Class::Manual::Cookbook/"Predefined searches">
+for more info.
+
+=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>
+ </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
+ connect_info:
+ dsn: dbi:Oracle:mydb
+ user: mtfnpy
+ password: mypass
+ LongReadLen: 1000000
+ LongTruncOk: 1
+ on_connect_do: [ "alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'" ]
+ cursor_class: 'DBIx::Class::Cursor::Cached'
+ 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>
+
+=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 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 storage
+
+Provides an accessor for the connected schema's storage object.
+Used often for debugging and controlling transactions.
+
+=cut
+
+has schema => (is => 'rw', isa => 'DBIx::Class::Schema');
+
+has schema_class => (
+ is => 'ro',
+ isa => LoadedClass,
+ 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
+);
+
+sub BUILD {
+ my $self = shift;
+ 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($self);
+ }
+ }
+
+ 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;
+
+ $self->composed_schema($schema_class->compose_namespace($class));
+
+ $self->schema($self->composed_schema->clone);
+
+ $self->schema->storage_type($self->storage_type)
+ if $self->storage_type;
+
+ $self->schema->connection($self->connect_info);
+
+ $self->_install_rs_models;
+}
+
+sub clone { shift->composed_schema->clone(@_); }
+
+sub connect { shift->composed_schema->connect(@_); }
+
+sub storage { shift->schema->storage(@_); }
+
+sub resultset { shift->schema->resultset(@_); }
+
+=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 => >>.
+
+=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;
+
+ die "No sources found (did you forget to define your tables?)"
+ unless @sources;
+
+ 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 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<MooseX::Object::Pluggable>
+
+Traits:
+
+L<Catalyst::TraitFor::Model::DBIC::Schema::Caching>,
+L<Catalyst::TraitFor::Model::DBIC::Schema::Replicated>
+
+=head1 AUTHOR
+
+Brandon L Black, C<blblack at gmail.com>
+
+Contributors:
+
+Rafael Kitover, C<rkitover at cpan.org>
+
+=head1 COPYRIGHT
+
+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:
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC)
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema)
Deleted: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,122 +0,0 @@
-package Catalyst::TraitFor::Model::DBIC::Schema::Caching;
-
-use namespace::autoclean;
-use Moose::Role;
-use Carp::Clan '^Catalyst::Model::DBIC::Schema';
-use MooseX::Types::Moose 'Int';
-
-=head1 NAME
-
-Catalyst::TraitFor::Model::DBIC::Schema::Caching - Query caching support for
-Catalyst::Model::DBIC::Schema
-
-=head1 SYNOPSIS
-
- __PACKAGE__->config({
- traits => ['Caching'],
- connect_info =>
- ['dbi:mysql:db', 'user', 'pass'],
- });
-
- $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 });
-
-=head1 DESCRIPTION
-
-Enable caching support using L<DBIx::Class::Cursor::Cached> and
-L<Catalyst::Plugin::Cache>.
-
-In order for this to work, L<Catalyst::Plugin::Cache> must be configured and
-loaded. A possible configuration would look like this:
-
- <Plugin::Cache>
- <backend>
- class Cache::FastMmap
- unlink_on_exit 1
- share_file /tmp/myapp_share
- </backend>
- </Plugin::Cache>
-
-Then in your queries, set the C<cache_for> ResultSet attribute to the number of
-seconds you want the query results to be cached for, eg.:
-
- $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 });
-
-=head1 CONFIG PARAMETERS
-
-=head2 caching
-
-Turn caching on or off, you can use:
-
- $c->model('DB')->caching(0);
-
-=cut
-
-has caching => (is => 'rw', isa => Int, default => 1);
-
-after setup => sub {
- my $self = shift;
-
- return if !$self->caching;
-
- $self->caching(0);
-
- my $cursor_class = $self->connect_info->{cursor_class}
- || 'DBIx::Class::Cursor::Cached';
-
- unless (eval { Class::MOP::load_class($cursor_class) }) {
- carp "Caching disabled, cannot load cursor class"
- . " $cursor_class: $@";
- return;
- }
-
- unless ($cursor_class->can('clear_cache')) {
- carp "Caching disabled, cursor_class $cursor_class does not"
- . " support it.";
- return;
- }
-
- $self->connect_info->{cursor_class} = $cursor_class;
- $self->caching(1);
-};
-
-before ACCEPT_CONTEXT => sub {
- my ($self, $c) = @_;
-
- return $self unless
- $self->caching;
-
- unless ($c->can('cache') && ref $c->cache) {
- $c->log->warn("DBIx::Class cursor caching disabled, you don't seem to"
- . " have a working Cache plugin.");
- $self->caching(0);
- $self->_reset_cursor_class;
- return $self;
- }
-
- if (ref $self->schema->default_resultset_attributes) {
- $self->schema->default_resultset_attributes->{cache_object} =
- $c->cache;
- } else {
- $self->schema->default_resultset_attributes({
- cache_object => $c->cache
- });
- }
-};
-
-=head1 SEE ALSO
-
-L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class>, L<Catalyst::Plugin::Cache>,
-L<Cache::FastMmap>, L<DBIx::Class::Cursor::Cached>
-
-=head1 AUTHOR
-
-Rafael Kitover, C<rkitover at cpan.org>
-
-=head1 COPYRIGHT
-
-This program is free software, you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-=cut
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Caching.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,122 @@
+package Catalyst::TraitFor::Model::DBIC::Schema::Caching;
+
+use namespace::autoclean;
+use Moose::Role;
+use Carp::Clan '^Catalyst::Model::DBIC::Schema';
+use MooseX::Types::Moose 'Int';
+
+=head1 NAME
+
+Catalyst::TraitFor::Model::DBIC::Schema::Caching - Query caching support for
+Catalyst::Model::DBIC::Schema
+
+=head1 SYNOPSIS
+
+ __PACKAGE__->config({
+ traits => ['Caching'],
+ connect_info =>
+ ['dbi:mysql:db', 'user', 'pass'],
+ });
+
+ $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 });
+
+=head1 DESCRIPTION
+
+Enable caching support using L<DBIx::Class::Cursor::Cached> and
+L<Catalyst::Plugin::Cache>.
+
+In order for this to work, L<Catalyst::Plugin::Cache> must be configured and
+loaded. A possible configuration would look like this:
+
+ <Plugin::Cache>
+ <backend>
+ class Cache::FastMmap
+ unlink_on_exit 1
+ share_file /tmp/myapp_share
+ </backend>
+ </Plugin::Cache>
+
+Then in your queries, set the C<cache_for> ResultSet attribute to the number of
+seconds you want the query results to be cached for, eg.:
+
+ $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 });
+
+=head1 CONFIG PARAMETERS
+
+=head2 caching
+
+Turn caching on or off, you can use:
+
+ $c->model('DB')->caching(0);
+
+=cut
+
+has caching => (is => 'rw', isa => Int, default => 1);
+
+after setup => sub {
+ my $self = shift;
+
+ return if !$self->caching;
+
+ $self->caching(0);
+
+ my $cursor_class = $self->connect_info->{cursor_class}
+ || 'DBIx::Class::Cursor::Cached';
+
+ unless (eval { Class::MOP::load_class($cursor_class) }) {
+ carp "Caching disabled, cannot load cursor class"
+ . " $cursor_class: $@";
+ return;
+ }
+
+ unless ($cursor_class->can('clear_cache')) {
+ carp "Caching disabled, cursor_class $cursor_class does not"
+ . " support it.";
+ return;
+ }
+
+ $self->connect_info->{cursor_class} = $cursor_class;
+ $self->caching(1);
+};
+
+before ACCEPT_CONTEXT => sub {
+ my ($self, $c) = @_;
+
+ return $self unless
+ $self->caching;
+
+ unless ($c->can('cache') && ref $c->cache) {
+ $c->log->warn("DBIx::Class cursor caching disabled, you don't seem to"
+ . " have a working Cache plugin.");
+ $self->caching(0);
+ $self->_reset_cursor_class;
+ return $self;
+ }
+
+ if (ref $self->schema->default_resultset_attributes) {
+ $self->schema->default_resultset_attributes->{cache_object} =
+ $c->cache;
+ } else {
+ $self->schema->default_resultset_attributes({
+ cache_object => $c->cache
+ });
+ }
+};
+
+=head1 SEE ALSO
+
+L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class>, L<Catalyst::Plugin::Cache>,
+L<Cache::FastMmap>, L<DBIx::Class::Cursor::Cached>
+
+=head1 AUTHOR
+
+Rafael Kitover, C<rkitover at cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
Deleted: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,141 +0,0 @@
-package Catalyst::TraitFor::Model::DBIC::Schema::Replicated;
-
-use namespace::autoclean;
-use Moose::Role;
-use Moose::Autobox;
-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->flatten);
-};
-
-=head1 SEE ALSO
-
-L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class>,
-L<DBIx::Class::Storage::DBI::Replicated>,
-L<Cache::FastMmap>, L<DBIx::Class::Cursor::Cached>
-
-=head1 AUTHOR
-
-Rafael Kitover, C<rkitover at cpan.org>
-
-=head1 COPYRIGHT
-
-This program is free software, you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-=cut
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/TraitFor/Model/DBIC/Schema/Replicated.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,141 @@
+package Catalyst::TraitFor::Model::DBIC::Schema::Replicated;
+
+use namespace::autoclean;
+use Moose::Role;
+use Moose::Autobox;
+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->flatten);
+};
+
+=head1 SEE ALSO
+
+L<Catalyst::Model::DBIC::Schema>, L<DBIx::Class>,
+L<DBIx::Class::Storage::DBI::Replicated>,
+L<Cache::FastMmap>, L<DBIx::Class::Cursor::Cached>
+
+=head1 AUTHOR
+
+Rafael Kitover, C<rkitover at cpan.org>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t)
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/01use.t
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/01use.t 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/01use.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,5 +0,0 @@
-use strict;
-use Test::More tests => 2;
-
-BEGIN { use_ok('Catalyst::Model::DBIC::Schema') }
-BEGIN { use_ok('Catalyst::Helper::Model::DBIC::Schema') }
Copied: trunk/Catalyst-Model-DBIC-Schema/t/01use.t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/01use.t)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/01use.t (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/01use.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,5 @@
+use strict;
+use Test::More tests => 2;
+
+BEGIN { use_ok('Catalyst::Model::DBIC::Schema') }
+BEGIN { use_ok('Catalyst::Helper::Model::DBIC::Schema') }
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/02pod.t
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/02pod.t 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/02pod.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,8 +0,0 @@
-use Test::More;
-
-eval "use Test::Pod 1.14";
-plan skip_all => 'Test::Pod 1.14 required' if $@;
-plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
-
-all_pod_files_ok();
-
Copied: trunk/Catalyst-Model-DBIC-Schema/t/02pod.t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/02pod.t)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/02pod.t (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/02pod.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,8 @@
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_files_ok();
+
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,80 +0,0 @@
-use strict;
-use Test::More;
-use FindBin;
-use File::Spec;
-use File::Find;
-
-plan skip_all => 'Enable this optional test with $ENV{C_M_DBIC_SCHEMA_TESTAPP}'
- unless $ENV{C_M_DBIC_SCHEMA_TESTAPP};
-
-# XXX this test needs a re-write to fully test the current set of capabilities...
-
-my $test_params = [
- [ 'TestSchema', 'DBIC::Schema', '' ],
- [ 'TestSchemaDSN', 'DBIC::Schema', q{fakedsn fakeuser fakepass "{ AutoCommit => 1 }"} ],
- [ 'TestSchemaDSN', 'DBIC::Schema', q{create=static traits=Caching moniker_map="{ roles => \"ROLE\" }" constraint="^users\z" dbi:SQLite:testdb.db} ],
- [ 'TestSchemaDSN', 'DBIC::Schema', q{create=static traits=Caching moniker_map="{ roles => \"ROLE\" }" constraint="^users\z" dbi:SQLite:testdb.db "" "" on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\""} ],
- [ 'TestSchemaDSN', 'DBIC::Schema', q{create=static traits=Caching moniker_map="{ roles => \"ROLE\" }" dbi:SQLite:testdb.db on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\""} ],
-];
-
-plan tests => (2 * @$test_params + 3);
-
-my $test_dir = $FindBin::Bin;
-my $blib_dir = File::Spec->catdir ($test_dir, '..', 'blib', 'lib');
-my $cat_dir = File::Spec->catdir ($test_dir, 'TestApp');
-my $catlib_dir = File::Spec->catdir ($cat_dir, 'lib');
-my $schema_dir = File::Spec->catdir ($catlib_dir, 'TestSchemaDSN');
-my $creator = File::Spec->catfile($cat_dir, 'script', 'testapp_create.pl');
-my $model_dir = File::Spec->catdir ($catlib_dir, 'TestApp', 'Model');
-my $db = File::Spec->catdir ($cat_dir, 'testdb.db');
-
-chdir($test_dir);
-system("catalyst.pl TestApp");
-chdir($cat_dir);
-
-# create test db
-open my $sql, '|-', 'sqlite3', $db or die $!;
-print $sql <<'EOF';
-CREATE TABLE users (
- id INTEGER PRIMARY KEY,
- username TEXT,
- password TEXT,
- email_address TEXT,
- first_name TEXT,
- last_name TEXT,
- active INTEGER
-);
-CREATE TABLE roles (
- id INTEGER PRIMARY KEY,
- role TEXT
-);
-EOF
-close $sql;
-
-foreach my $tparam (@$test_params) {
- my ($model, $helper, $args) = @$tparam;
- system("$^X -I$blib_dir $creator model $model $helper $model $args");
- my $model_path = File::Spec->catfile($model_dir, $model . '.pm');
- ok( -f $model_path, "$model_path is a file" );
- my $compile_rv = system("$^X -I$blib_dir -I$catlib_dir -c $model_path");
- ok($compile_rv == 0, "perl -c $model_path");
-
- if ($args =~ /create=static/) {
- my $glob = File::Spec->catfile($schema_dir, 'Result', '*');
- my $tables =()= glob($glob);
- if ($args =~ /constraint/) {
- is $tables, 1, 'constraint works';
- } else {
- is $tables, 2, 'correct number of tables';
- }
- }
-}
-
-chdir($test_dir);
-
-sub rm_rf {
- my $name = $File::Find::name;
- if(-d $name) { rmdir $name or die "Cannot rmdir $name: $!" }
- else { unlink $name or die "Cannot unlink $name: $!" }
-}
-finddepth(\&rm_rf, $cat_dir);
Copied: trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/05testapp.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,80 @@
+use strict;
+use Test::More;
+use FindBin;
+use File::Spec;
+use File::Find;
+
+plan skip_all => 'Enable this optional test with $ENV{C_M_DBIC_SCHEMA_TESTAPP}'
+ unless $ENV{C_M_DBIC_SCHEMA_TESTAPP};
+
+# XXX this test needs a re-write to fully test the current set of capabilities...
+
+my $test_params = [
+ [ 'TestSchema', 'DBIC::Schema', '' ],
+ [ 'TestSchemaDSN', 'DBIC::Schema', q{fakedsn fakeuser fakepass "{ AutoCommit => 1 }"} ],
+ [ 'TestSchemaDSN', 'DBIC::Schema', q{create=static traits=Caching moniker_map="{ roles => \"ROLE\" }" constraint="^users\z" dbi:SQLite:testdb.db} ],
+ [ 'TestSchemaDSN', 'DBIC::Schema', q{create=static traits=Caching moniker_map="{ roles => \"ROLE\" }" constraint="^users\z" dbi:SQLite:testdb.db "" "" on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\""} ],
+ [ 'TestSchemaDSN', 'DBIC::Schema', q{create=static traits=Caching moniker_map="{ roles => \"ROLE\" }" dbi:SQLite:testdb.db on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\""} ],
+];
+
+plan tests => (2 * @$test_params + 3);
+
+my $test_dir = $FindBin::Bin;
+my $blib_dir = File::Spec->catdir ($test_dir, '..', 'blib', 'lib');
+my $cat_dir = File::Spec->catdir ($test_dir, 'TestApp');
+my $catlib_dir = File::Spec->catdir ($cat_dir, 'lib');
+my $schema_dir = File::Spec->catdir ($catlib_dir, 'TestSchemaDSN');
+my $creator = File::Spec->catfile($cat_dir, 'script', 'testapp_create.pl');
+my $model_dir = File::Spec->catdir ($catlib_dir, 'TestApp', 'Model');
+my $db = File::Spec->catdir ($cat_dir, 'testdb.db');
+
+chdir($test_dir);
+system("catalyst.pl TestApp");
+chdir($cat_dir);
+
+# create test db
+open my $sql, '|-', 'sqlite3', $db or die $!;
+print $sql <<'EOF';
+CREATE TABLE users (
+ id INTEGER PRIMARY KEY,
+ username TEXT,
+ password TEXT,
+ email_address TEXT,
+ first_name TEXT,
+ last_name TEXT,
+ active INTEGER
+);
+CREATE TABLE roles (
+ id INTEGER PRIMARY KEY,
+ role TEXT
+);
+EOF
+close $sql;
+
+foreach my $tparam (@$test_params) {
+ my ($model, $helper, $args) = @$tparam;
+ system("$^X -I$blib_dir $creator model $model $helper $model $args");
+ my $model_path = File::Spec->catfile($model_dir, $model . '.pm');
+ ok( -f $model_path, "$model_path is a file" );
+ my $compile_rv = system("$^X -I$blib_dir -I$catlib_dir -c $model_path");
+ ok($compile_rv == 0, "perl -c $model_path");
+
+ if ($args =~ /create=static/) {
+ my $glob = File::Spec->catfile($schema_dir, 'Result', '*');
+ my $tables =()= glob($glob);
+ if ($args =~ /constraint/) {
+ is $tables, 1, 'constraint works';
+ } else {
+ is $tables, 2, 'correct number of tables';
+ }
+ }
+}
+
+chdir($test_dir);
+
+sub rm_rf {
+ my $name = $File::Find::name;
+ if(-d $name) { rmdir $name or die "Cannot rmdir $name: $!" }
+ else { unlink $name or die "Cannot unlink $name: $!" }
+}
+finddepth(\&rm_rf, $cat_dir);
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,16 +0,0 @@
-use strict;
-use warnings;
-
-use FindBin qw/$Bin/;
-use lib "$Bin/lib";
-
-use Test::More tests => 1;
-
-# This fails for me on 5.8.8 with the following module versions:
-#
-# Class:C3 0.21
-# Class::C3::Componentised 1.0005
-# DBIx::Class 0.08013 (0.08099_05 works)
-
-use TestAppC3Fail;
-
Copied: trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/06c3_issues.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+
+use Test::More tests => 1;
+
+# This fails for me on 5.8.8 with the following module versions:
+#
+# Class:C3 0.21
+# Class::C3::Componentised 1.0005
+# DBIx::Class 0.08013 (0.08099_05 works)
+
+use TestAppC3Fail;
+
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,104 +0,0 @@
-use strict;
-use warnings;
-
-use FindBin '$Bin';
-use lib "$Bin/lib";
-
-use Test::More;
-use Test::Exception;
-use Catalyst::Model::DBIC::Schema;
-use ASchemaClass;
-
-# execise the connect_info coercion
-
-my @tests = (
- ['dbi:SQLite:foo.db', '', ''],
- { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
-
- ['dbi:SQLite:foo.db', ''],
- { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
-
- ['dbi:SQLite:foo.db'],
- { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
-
- 'dbi:SQLite:foo.db',
- { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
-
- ['dbi:Pg:dbname=foo', 'user', 'pass',
- { pg_enable_utf8 => 1, auto_savepoint => 1 }],
- { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
- pg_enable_utf8 => 1, auto_savepoint => 1 },
-
- ['dbi:Pg:dbname=foo', 'user', 'pass',
- { pg_enable_utf8 => 1 }, { auto_savepoint => 1 }],
- { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
- pg_enable_utf8 => 1, auto_savepoint => 1 },
-
- [ { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
- pg_enable_utf8 => 1, auto_savepoint => 1 } ],
- { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
- pg_enable_utf8 => 1, auto_savepoint => 1 },
-);
-
-my @invalid = (
- { foo => 'bar' },
- [ { foo => 'bar' } ],
- ['dbi:Pg:dbname=foo', 'user', 'pass',
- { pg_enable_utf8 => 1 }, { AutoCommit => 1 }, { auto_savepoint => 1 }],
-);
-
-plan tests => @tests / 2 + @invalid + 1 + 1;
-
-# ignore redefined warnings, and uninitialized warnings from old
-# ::Storage::DBI::Replicated
-local $SIG{__WARN__} = sub {
- $_[0] !~ /(?:redefined|uninitialized)/i && warn @_
-};
-
-for (my $i = 0; $i < @tests; $i += 2) {
- my $m = instance(
- connect_info => $tests[$i]
- );
-
- is_deeply $m->connect_info, $tests[$i+1],
- 'connect_info coerced correctly';
-}
-
-throws_ok { instance(connect_info => $_) } qr/valid connect_info/i,
- 'invalid connect_info throws exception'
- for @invalid;
-
-# try as ConnectInfos (e.g.: replicants)
-my @replicants = map $tests[$_], grep $_ % 2 == 0, 0..$#tests;
-
-{
- package TryConnectInfos;
-
- use Moose;
- use Catalyst::Model::DBIC::Schema::Types 'ConnectInfos';
-
- has replicants => (is => 'ro', isa => ConnectInfos, coerce => 1);
-}
-
-my $m = TryConnectInfos->new(
- replicants => \@replicants
-);
-
-is_deeply $m->replicants, [
- map $tests[$_], grep $_ % 2, 0 .. $#tests
-], 'replicant connect_infos coerced correctly';
-
-{
- ASchemaClass->connection( @{$tests[0]} );
- my $m = instance();
-
- is_deeply $m->connect_info, $tests[1],
- 'connect_info coerced correctly when defining connection in the schema class';
-}
-
-sub instance {
- Catalyst::Model::DBIC::Schema->new({
- schema_class => 'ASchemaClass',
- @_
- })
-}
Copied: trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/07connect_info.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,104 @@
+use strict;
+use warnings;
+
+use FindBin '$Bin';
+use lib "$Bin/lib";
+
+use Test::More;
+use Test::Exception;
+use Catalyst::Model::DBIC::Schema;
+use ASchemaClass;
+
+# execise the connect_info coercion
+
+my @tests = (
+ ['dbi:SQLite:foo.db', '', ''],
+ { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
+
+ ['dbi:SQLite:foo.db', ''],
+ { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
+
+ ['dbi:SQLite:foo.db'],
+ { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
+
+ 'dbi:SQLite:foo.db',
+ { dsn => 'dbi:SQLite:foo.db', user => '', password => '' },
+
+ ['dbi:Pg:dbname=foo', 'user', 'pass',
+ { pg_enable_utf8 => 1, auto_savepoint => 1 }],
+ { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
+ pg_enable_utf8 => 1, auto_savepoint => 1 },
+
+ ['dbi:Pg:dbname=foo', 'user', 'pass',
+ { pg_enable_utf8 => 1 }, { auto_savepoint => 1 }],
+ { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
+ pg_enable_utf8 => 1, auto_savepoint => 1 },
+
+ [ { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
+ pg_enable_utf8 => 1, auto_savepoint => 1 } ],
+ { dsn => 'dbi:Pg:dbname=foo', user => 'user', password => 'pass',
+ pg_enable_utf8 => 1, auto_savepoint => 1 },
+);
+
+my @invalid = (
+ { foo => 'bar' },
+ [ { foo => 'bar' } ],
+ ['dbi:Pg:dbname=foo', 'user', 'pass',
+ { pg_enable_utf8 => 1 }, { AutoCommit => 1 }, { auto_savepoint => 1 }],
+);
+
+plan tests => @tests / 2 + @invalid + 1 + 1;
+
+# ignore redefined warnings, and uninitialized warnings from old
+# ::Storage::DBI::Replicated
+local $SIG{__WARN__} = sub {
+ $_[0] !~ /(?:redefined|uninitialized)/i && warn @_
+};
+
+for (my $i = 0; $i < @tests; $i += 2) {
+ my $m = instance(
+ connect_info => $tests[$i]
+ );
+
+ is_deeply $m->connect_info, $tests[$i+1],
+ 'connect_info coerced correctly';
+}
+
+throws_ok { instance(connect_info => $_) } qr/valid connect_info/i,
+ 'invalid connect_info throws exception'
+ for @invalid;
+
+# try as ConnectInfos (e.g.: replicants)
+my @replicants = map $tests[$_], grep $_ % 2 == 0, 0..$#tests;
+
+{
+ package TryConnectInfos;
+
+ use Moose;
+ use Catalyst::Model::DBIC::Schema::Types 'ConnectInfos';
+
+ has replicants => (is => 'ro', isa => ConnectInfos, coerce => 1);
+}
+
+my $m = TryConnectInfos->new(
+ replicants => \@replicants
+);
+
+is_deeply $m->replicants, [
+ map $tests[$_], grep $_ % 2, 0 .. $#tests
+], 'replicant connect_infos coerced correctly';
+
+{
+ ASchemaClass->connection( @{$tests[0]} );
+ my $m = instance();
+
+ is_deeply $m->connect_info, $tests[1],
+ 'connect_info coerced correctly when defining connection in the schema class';
+}
+
+sub instance {
+ Catalyst::Model::DBIC::Schema->new({
+ schema_class => 'ASchemaClass',
+ @_
+ })
+}
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/08helper.t
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/08helper.t 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/08helper.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,166 +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 $@;
-plan tests => 41;
-
-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, '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';
-
-sub instance {
- Catalyst::Helper::Model::DBIC::Schema->new(
- schema_class => 'AnotherSchemaClass',
- helper => dclone($helper),
- args => ['create=static'],
- @_
- )
-}
Copied: trunk/Catalyst-Model-DBIC-Schema/t/08helper.t (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/08helper.t)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/08helper.t (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/08helper.t 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,166 @@
+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 $@;
+plan tests => 41;
+
+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, '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';
+
+sub instance {
+ Catalyst::Helper::Model::DBIC::Schema->new(
+ schema_class => 'AnotherSchemaClass',
+ helper => dclone($helper),
+ args => ['create=static'],
+ @_
+ )
+}
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib)
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass)
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,13 +0,0 @@
-package ASchemaClass::Users;
-
-# empty schemas no longer work
-
-use strict;
-use warnings;
-
-use base 'DBIx::Class';
-
-__PACKAGE__->load_components("Core");
-__PACKAGE__->table("users");
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass/Users.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,13 @@
+package ASchemaClass::Users;
+
+# empty schemas no longer work
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("users");
+
+1;
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,7 +0,0 @@
-package ASchemaClass;
-
-use base 'DBIx::Class::Schema';
-
-__PACKAGE__->load_classes;
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/ASchemaClass.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,7 @@
+package ASchemaClass;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass)
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result)
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,13 +0,0 @@
-package AnotherSchemaClass::Result::Users;
-
-# empty schemas no longer work
-
-use strict;
-use warnings;
-
-use base 'DBIx::Class';
-
-__PACKAGE__->load_components("Core");
-__PACKAGE__->table("users");
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass/Result/Users.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,13 @@
+package AnotherSchemaClass::Result::Users;
+
+# empty schemas no longer work
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("users");
+
+1;
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,7 +0,0 @@
-package AnotherSchemaClass;
-
-use base 'DBIx::Class::Schema';
-
-__PACKAGE__->load_namespaces;
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/AnotherSchemaClass.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,7 @@
+package AnotherSchemaClass;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_namespaces;
+
+1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail)
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model)
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,11 +0,0 @@
-package TestAppC3Fail::Model::DB;
-use strict;
-use warnings;
-use base 'Catalyst::Model::DBIC::Schema';
-
-__PACKAGE__->config(
- schema_class => 'TestAppC3Fail::Schema::DB',
- connect_info => [ 'DBI:SQLite:dbname=foo', '', '' ],
-);
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Model/DB.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,11 @@
+package TestAppC3Fail::Model::DB;
+use strict;
+use warnings;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'TestAppC3Fail::Schema::DB',
+ connect_info => [ 'DBI:SQLite:dbname=foo', '', '' ],
+);
+
+1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema)
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB)
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,13 +0,0 @@
-package TestAppC3Fail::Schema::DB::Users;
-
-# empty schemas no longer work
-
-use strict;
-use warnings;
-
-use base 'DBIx::Class';
-
-__PACKAGE__->load_components("Core");
-__PACKAGE__->table("users");
-
-1;
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB/Users.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,13 @@
+package TestAppC3Fail::Schema::DB::Users;
+
+# empty schemas no longer work
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("users");
+
+1;
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,11 +0,0 @@
-package TestAppC3Fail::Schema::DB;
-
-use strict;
-use warnings;
-
-use base 'DBIx::Class::Schema';
-
-__PACKAGE__->load_classes;
-
-1;
-
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail/Schema/DB.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,11 @@
+package TestAppC3Fail::Schema::DB;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+1;
+
Deleted: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm 2009-07-24 16:12:19 UTC (rev 10972)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -1,25 +0,0 @@
-package TestAppC3Fail;
-use strict;
-use warnings;
-use Class::C3; # This causes the fail, saying use MRO::Compat is fine..
-
-our $VERSION = '0.0001';
-
-use Catalyst::Runtime '5.70';
-use Catalyst;
-
-__PACKAGE__->config(
- name => 'TestAppC3Fail',
-);
-
-my @keys = sort keys( %{ __PACKAGE__->config } );
-
-__PACKAGE__->setup;
-
-my @new_keys = sort keys( %{ __PACKAGE__->config } );
-use Test::More;
-
-is_deeply(\@new_keys, \@keys, 'Config keys correct');
-
-1;
-
Copied: trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm (from rev 10972, trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm)
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm (rev 0)
+++ trunk/Catalyst-Model-DBIC-Schema/t/lib/TestAppC3Fail.pm 2009-07-29 21:54:10 UTC (rev 10999)
@@ -0,0 +1,25 @@
+package TestAppC3Fail;
+use strict;
+use warnings;
+use Class::C3; # This causes the fail, saying use MRO::Compat is fine..
+
+our $VERSION = '0.0001';
+
+use Catalyst::Runtime '5.70';
+use Catalyst;
+
+__PACKAGE__->config(
+ name => 'TestAppC3Fail',
+);
+
+my @keys = sort keys( %{ __PACKAGE__->config } );
+
+__PACKAGE__->setup;
+
+my @new_keys = sort keys( %{ __PACKAGE__->config } );
+use Test::More;
+
+is_deeply(\@new_keys, \@keys, 'Config keys correct');
+
+1;
+
More information about the Catalyst-commits
mailing list