remove dist files generated by M::B, add on_connect_do support from Alexander Hartmai...
Brandon L. Black [Wed, 22 Mar 2006 07:03:47 +0000 (07:03 +0000)]
Changes
MANIFEST [deleted file]
META.yml [deleted file]
README [deleted file]
lib/Catalyst/Model/DBIC/Schema.pm

diff --git a/Changes b/Changes
index 57cfb74..8d6860c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for Perl extension Catalyst::Model::DBIC::Schema
 
-0.09  Not released yet
+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
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644 (file)
index 2c3afd7..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,14 +0,0 @@
-Build.PL
-Changes
-lib/Catalyst/Helper/Model/DBIC/Schema.pm
-lib/Catalyst/Helper/Model/DBIC/SchemaLoader.pm
-lib/Catalyst/Model/DBIC/Schema.pm
-Makefile.PL
-MANIFEST                       This list of files
-META.yml
-README
-t/01use.t
-t/02pod.t
-t/03podcoverage.t
-t/04kwalitee.t
-t/05testapp.t
diff --git a/META.yml b/META.yml
deleted file mode 100644 (file)
index a0f2aed..0000000
--- a/META.yml
+++ /dev/null
@@ -1,26 +0,0 @@
----
-name: Catalyst-Model-DBIC-Schema
-version: 0.10
-author:
-  - 'Brandon L Black, C<blblack@gmail.com>'
-abstract: DBIx::Class::Schema Model Class
-license: perl
-requires:
-  Catalyst: 5.64
-  Class::Accessor::Fast: 0.22
-  Class::Data::Accessor: 0.02
-  DBIx::Class: 0.05006
-  UNIVERSAL::require: 0.1
-recommends:
-  DBIx::Class::Schema::Loader: 0.02003
-build_requires:
-  Test::More: 0.32
-provides:
-  Catalyst::Helper::Model::DBIC::Schema:
-    file: lib/Catalyst/Helper/Model/DBIC/Schema.pm
-  Catalyst::Helper::Model::DBIC::SchemaLoader:
-    file: lib/Catalyst/Helper/Model/DBIC/SchemaLoader.pm
-  Catalyst::Model::DBIC::Schema:
-    file: lib/Catalyst/Model/DBIC/Schema.pm
-    version: 0.10
-generated_by: Module::Build version 0.2611
diff --git a/README b/README
deleted file mode 100644 (file)
index e35d435..0000000
--- a/README
+++ /dev/null
@@ -1,136 +0,0 @@
-NAME
-    Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
-
-SYNOPSIS
-        package MyApp::Model::Foo;
-        use strict;
-        use base 'Catalyst::Model::DBIC::Schema';
-
-        __PACKAGE__->config(
-            schema_class => 'Foo::SchemaClass',
-            connect_info => [ 'dbi:Pg:dbname=foodb',
-                              'postgres',
-                              '',
-                              { AutoCommit => 1 },
-                            ],
-        );
-
-        1;
-
-        # In controller code:
-
-        # ->schema To access schema methods:
-        $c->model('Foo')->schema->source(...);
-
-        # certain ->schema methods (source, resultset, class) have shortcuts
-        $c->model('Foo')->source(...);
-        $c->model('Foo')->resultset(...);
-        $c->model('Foo')->class(...);
-
-        # For resultsets, there's an even quicker shortcut:
-        $c->model('Foo::Bar')
-        # is the same as $c->model('Foo')->resultset('Bar')
-
-        # To get the composed schema for making new connections:
-        my $newconn = $c->model('Foo')->composed_schema->connect(...);
-
-        # Or the same thing via a convenience shortcut:
-        my $newconn = $c->model('Foo')->connect(...);
-
-        # or, if your schema works on different storage drivers:
-        my $newconn = $c->model('Foo')->composed_schema->clone();
-        $newconn->storage_type('::LDAP');
-        $newconn->connection(...);
-
-        # and again, a convenience shortcut
-        my $newconn = $c->model('Foo')->clone();
-        $newconn->storage_type('::LDAP');
-        $newconn->connection(...);
-
-DESCRIPTION
-    This is a Catalyst Model for DBIx::Class::Schema-based Models. See the
-    documentation for Catalyst::Helper::Model::DBIC::Schema and
-    Catalyst::Helper::Model::DBIC::SchemaLoader for information on
-    generating these Models via Helper scripts. The latter of the two will
-    also generated a DBIx::Class::Schema::Loader-based Schema class for you.
-
-CONFIG PARAMETERS
-    schema_class
-        This is the classname of your DBIx::Class::Schema Schema. It needs
-        to be findable in @INC, but it does not need to be underneath
-        "Catalyst::Model::". This parameter is required.
-
-    connect_info
-        This is an arrayref of connection parameters, which are specific to
-        your "storage_type". For "::DBI", which is the only supported
-        "storage_type" in DBIx::Class at the time of this writing, the 4
-        parameters are your dsn, username, password, and connect options
-        hashref.
-
-        This is not required if "schema_class" already has connection
-        information defined in itself (which would be the case for a Schema
-        defined by DBIx::Class::Schema::Loader, for instance).
-
-    storage_type
-        Allows the use of a different "storage_type" than what is set in
-        your "schema_class" (which in turn defaults to "::DBI" if not set in
-        current DBIx::Class). Completely optional, and probably unnecessary
-        for most people until other storage backends become available for
-        DBIx::Class.
-
-METHODS
-    new Instantiates the Model based on the above-documented ->config
-        parameters. The only required parameter is "schema_class".
-        "connect_info" is required in the case that "schema_class" does not
-        already have connection information defined for it.
-
-    schema
-        Accessor which returns the connected schema being used by the this
-        model. There are already direct shortcuts on the model class itself
-        for schema->resultset, schema->source, and schema->class.
-
-    composed_schema
-        Accessor which returns the composed schema, which has no connection
-        info, which was used in constructing the "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
-
-    clone
-        Shortcut for ->composed_schema->clone
-
-    connect
-        Shortcut for ->composed_schema->connect
-
-    source
-        Shortcut for ->schema->source
-
-    class
-        Shortcut for ->schema->class
-
-    resultset
-        Shortcut for ->schema->resultset
-
-    storage
-        Provides an accessor for the connected schema's storage object. Used
-        often for debugging and controlling transactions.
-
-SEE ALSO
-    General Catalyst Stuff:
-
-    Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response,
-    Catalyst::Helper, Catalyst,
-
-    Stuff related to DBIC and this Model style:
-
-    DBIx::Class, DBIx::Class::Schema, DBIx::Class::Schema::Loader,
-    Catalyst::Helper::Model::DBIC::Schema,
-    Catalyst::Helper::Model::DBIC::SchemaLoader
-
-AUTHOR
-    Brandon L Black, "blblack@gmail.com"
-
-COPYRIGHT
-    This program is free software, you can redistribute it and/or modify it
-    under the same terms as Perl itself.
-
index 712f4a7..16d012a 100644 (file)
@@ -22,12 +22,13 @@ Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
     use base 'Catalyst::Model::DBIC::Schema';
 
     __PACKAGE__->config(
-        schema_class => 'Foo::SchemaClass',
-        connect_info => [ 'dbi:Pg:dbname=foodb',
-                          'postgres',
-                          '',
-                          { AutoCommit => 1 },
-                        ],
+        schema_class    => 'Foo::SchemaClass',
+        connect_info    => [ 'dbi:Pg:dbname=foodb',
+                             'postgres',
+                             '',
+                             { AutoCommit => 1 },
+                           ],
+        on_connect_do   => [ 'sql statement 1', 'sql statement 2' ],
     );
 
     1;
@@ -92,6 +93,11 @@ This is not required if C<schema_class> already has connection information
 defined in itself (which would be the case for a Schema defined by
 L<DBIx::Class::Schema::Loader>, for instance).
 
+=item on_connect_do
+
+This is an arrayref of sql statements, which are executed on every connect.
+May not be a valid/useful argument with non-DBI-based Storages.
+
 =item storage_type
 
 Allows the use of a different C<storage_type> than what is set in your
@@ -181,8 +187,12 @@ sub new {
 
     $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->storage_type($self->{storage_type})
+        if $self->{storage_type};
     $self->schema->connection(@{$self->{connect_info}});
+    $self->schema->storage->on_connect_do($self->{on_connect_do})
+        if $self->{on_connect_do};
 
     no strict 'refs';
     foreach my $moniker ($self->schema->sources) {