Remove debugging code.
[catagits/Catalyst-Controller-DBIC-API.git] / lib / Catalyst / Controller / DBIC / API.pm
index 621015b..3a5919e 100644 (file)
@@ -66,7 +66,6 @@ A begin method is provided to apply the L<Catalyst::Controller::DBIC::API::Reque
 
 sub begin :Private
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
     
     Catalyst::Controller::DBIC::API::Request->meta->apply($c->req)
@@ -102,7 +101,6 @@ This action will populate $c->req->current_result_set with $self->stored_result_
 
 sub setup :Chained('specify.in.subclass.config') :CaptureArgs(0) :PathPart('specify.in.subclass.config')
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
 
     $c->req->_set_current_result_set($self->stored_result_source->resultset);
@@ -209,7 +207,6 @@ It should be noted that arguments can used mixed modes in with some caveats. Eac
 
 sub deserialize :ActionClass('Deserialize')
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
     my $req_params;
 
@@ -270,7 +267,6 @@ inflate_request is called at the end of deserialize to populate key portions of
 
 sub inflate_request
 {
-    $DB::single = 1;
     my ($self, $c, $params) = @_;
 
     try
@@ -329,7 +325,6 @@ Would result in this search:
 
 sub list :Private 
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
 
     $self->list_munge_parameters($c);
@@ -353,7 +348,6 @@ list_perform_search executes the actual search. current_result_set is updated to
 
 sub list_perform_search
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
     
     try 
@@ -387,7 +381,6 @@ list_format_output prepares the response for transmission across the wire. A cop
 
 sub list_format_output
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
 
     my $rs = $c->req->current_result_set->search;
@@ -438,13 +431,12 @@ update_or_create is responsible for iterating any stored objects and performing
 
 sub update_or_create :Private
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
     
     if($c->req->has_objects)
     {
         $self->validate_objects($c);
-        $self->transact_objects($c, sub { $self->save_objects(@_) } );
+        $self->transact_objects($c, sub { $self->save_objects($c, @_) } );
     }
     else
     {
@@ -462,7 +454,6 @@ transact_objects performs the actual commit to the database via $schema->txn_do.
 
 sub transact_objects
 {
-    $DB::single = 1;
     my ($self, $c, $coderef) = @_;
     
     try
@@ -489,7 +480,6 @@ This is a shortcut method for performing validation on all of the stored objects
 
 sub validate_objects
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
 
     try
@@ -517,7 +507,6 @@ validate_object takes the context and the object as an argument. It then filters
 
 sub validate_object
 {
-    $DB::single = 1;
     my ($self, $c, $obj) = @_;
     my ($object, $params) = @$obj;
 
@@ -612,12 +601,11 @@ delete operates on the stored objects in the request. It first transacts the obj
 
 sub delete :Private
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
     
     if($c->req->has_objects)
     {
-        $self->transact_objects($c, sub { $self->delete_objects(@_) });
+        $self->transact_objects($c, sub { $self->delete_objects($c, @_) });
         $c->req->clear_objects;
     }
     else
@@ -636,11 +624,11 @@ This method is used by update_or_create to perform the actual database manipulat
 
 sub save_objects
 {
-    my ($self, $objects) = @_;
+    my ($self, $c, $objects) = @_;
 
     foreach my $obj (@$objects)
     {
-        $self->save_object($obj);
+        $self->save_object($c, $obj);
     }
 }
 
@@ -652,17 +640,17 @@ save_object first checks to see if the object is already in storage. If so, it c
 
 sub save_object
 {
-    my ($self, $obj) = @_;
+    my ($self, $c, $obj) = @_;
 
     my ($object, $params) = @$obj;
 
     if ($object->in_storage)
     {
-        $self->update_object_from_params($object, $params);
+        $self->update_object_from_params($c, $object, $params);
     }
     else 
     {
-        $self->insert_object_from_params($object, $params);
+        $self->insert_object_from_params($c, $object, $params);
     }
 
 }
@@ -675,14 +663,14 @@ update_object_from_params iterates through the params to see if any of them are
 
 sub update_object_from_params
 {
-    my ($self, $object, $params) = @_;
+    my ($self, $c, $object, $params) = @_;
 
     foreach my $key (keys %$params)
     {
         my $value = $params->{$key};
         if (ref($value) && !($value == JSON::Any::true || $value == JSON::Any::false))
         {
-            $self->update_object_relation($object, delete $params->{$key}, $key);
+            $self->update_object_relation($c, $object, delete $params->{$key}, $key);
         }
     }
     
@@ -697,7 +685,7 @@ update_object_relation finds the relation to the object, then calls ->update wit
 
 sub update_object_relation
 {
-    my ($self, $object, $related_params, $relation) = @_;
+    my ($self, $c, $object, $related_params, $relation) = @_;
     my $row = $object->find_related($relation, {} , {});
     $row->update($related_params);
 }
@@ -710,7 +698,7 @@ insert_object_from_params sets the columns for the object, then calls ->insert
 
 sub insert_object_from_params
 {
-    my ($self, $object, $params) = @_;
+    my ($self, $c, $object, $params) = @_;
     $object->set_columns($params);
     $object->insert;
 }
@@ -723,9 +711,9 @@ delete_objects iterates through each object calling L</delete_object>
 
 sub delete_objects
 {
-    my ($self, $objects) = @_;
+    my ($self, $c, $objects) = @_;
 
-    map { $self->delete_object($_->[0]) } @$objects;
+    map { $self->delete_object($c, $_->[0]) } @$objects;
 }
 
 =method_protected delete_object
@@ -736,7 +724,7 @@ Performs the actual ->delete on the object
 
 sub delete_object
 {
-    my ($self, $object) = @_;
+    my ($self, $c, $object) = @_;
 
     $object->delete;
 }
@@ -751,7 +739,6 @@ end performs the final manipulation of the response before it is serialized. Thi
 
 sub end :Private 
 {
-    $DB::single = 1;
     my ($self, $c) = @_;
 
     # check for errors
@@ -776,7 +763,6 @@ sub end :Private
     }
     elsif($self->return_object && $c->req->has_objects)
     {
-        $DB::single = 1;
         my $returned_objects = [];
         push(@$returned_objects, $self->each_object_inflate($c, $_)) for map { $_->[0] } $c->req->all_objects;
         $c->stash->{response}->{$self->data_root} = scalar(@$returned_objects) > 1 ? $returned_objects : $returned_objects->[0];