[Bast-commits] r9907 - in DBIx-Class-UserStamp/1.000/trunk: . lib/DBIx/Class

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Tue Aug 9 09:08:23 GMT 2011


Author: t0m
Date: 2011-08-09 09:08:23 +0000 (Tue, 09 Aug 2011)
New Revision: 9907

Modified:
   DBIx-Class-UserStamp/1.000/trunk/Changes
   DBIx-Class-UserStamp/1.000/trunk/lib/DBIx/Class/UserStamp.pm
Log:
Fix SYNOPSIS - RT#70156

Modified: DBIx-Class-UserStamp/1.000/trunk/Changes
===================================================================
--- DBIx-Class-UserStamp/1.000/trunk/Changes	2011-08-09 09:05:27 UTC (rev 9906)
+++ DBIx-Class-UserStamp/1.000/trunk/Changes	2011-08-09 09:08:23 UTC (rev 9907)
@@ -1,4 +1,6 @@
         - Add repository metadata RT#70156
+        - Fix SYNOPSIS to note that $schema->clone
+          needs to be called. RT#70156
 
 0.11    2008-08-26
         - Port to DBIx::Class::DynamicDefault

Modified: DBIx-Class-UserStamp/1.000/trunk/lib/DBIx/Class/UserStamp.pm
===================================================================
--- DBIx-Class-UserStamp/1.000/trunk/lib/DBIx/Class/UserStamp.pm	2011-08-09 09:05:27 UTC (rev 9906)
+++ DBIx-Class-UserStamp/1.000/trunk/lib/DBIx/Class/UserStamp.pm	2011-08-09 09:08:23 UTC (rev 9907)
@@ -29,22 +29,27 @@
 
  package MyApp::Model::MyAppDB;
  use Moose;
+ use namespace::autoclean;
 
- around 'build_per_context_instance' => sub {
+ extends 'Catalyst::Model::DBIC::Schema';
+ with 'Catalyst::Component::InstancePerContext';
+
+ sub build_per_context_instance {
    my ($meth, $self) = (shift, shift);
    my ($c) = @_; # There are other params but we dont care about them
    my $new = bless({ %$self }, ref($self));
-   my $user_info = $c->_user_in_session; 
+   my $user_info = $c->_user_in_session;
+   $new->schema($new->schema->clone);
    my $user = $new->schema->resultset('User')->new_result({ %$user_info });
    $new->schema->current_user_id($user->id) if (defined $user_info);
    return $new;
- };
+ }
 
 
  package MyApp::Schema::SomeTable;
 
  __PACKAGE__->load_components(qw( UserStamp ... Core ));
- 
+
  __PACKAGE__->add_columns(
     id => { data_type => 'integer' },
     u_created => { data_type => 'int', store_user_on_create => 1 },
@@ -53,9 +58,9 @@
  );
 
 Now, any update or create actions will update the specified columns with the
-current user_id, using the current_user_id accessor.  
+current user_id, using the current_user_id accessor.
 
-This is effectively trigger emulation to ease user id field insertion 
+This is effectively trigger emulation to ease user id field insertion
 
 =cut
 




More information about the Bast-commits mailing list