X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FDBIC%2FAPI.pm;h=c173dcd85fc5b03e8ac77aa7e0e8a8319a7aca5b;hp=6f04263d6d644f5173dcab1b83a187d189b23399;hb=73517f507669cada16503d144607e42c86b65f64;hpb=2e978a8c3599cc9bc23ca3dd6e289f59c75c4e7e diff --git a/lib/Catalyst/Controller/DBIC/API.pm b/lib/Catalyst/Controller/DBIC/API.pm index 6f04263..c173dcd 100644 --- a/lib/Catalyst/Controller/DBIC/API.pm +++ b/lib/Catalyst/Controller/DBIC/API.pm @@ -66,7 +66,6 @@ A begin method is provided to apply the Lmeta->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); @@ -124,7 +122,7 @@ sub object :Chained('setup') :CaptureArgs(1) :PathPart('') unless(defined($vals)) { # no data root, assume the request_data itself is the payload - $vals = [$c->req->request_data || {}]; + $vals = [$c->req->request_data]; } elsif(reftype($vals) eq 'HASH') { @@ -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 @@ -297,7 +293,7 @@ sub inflate_request List level action chained from L. List's steps are broken up into three distinct methods: L, L, and L. -The goal of this method is to call ->search() on the current_result_set, HashRefInflator the result, and return it in $c->stash->{response}->{$self->data_root}. Pleasee see the individual methods for more details on what actual processing takes place. +The goal of this method is to call ->search() on the current_result_set, HashRefInflator the result, and return it in $c->stash->{response}->{$self->data_root}. Please see the individual methods for more details on what actual processing takes place. If the L config param is defined then the hashes will contain only those columns, otherwise all columns in the object will be returned. L of course supports the function/procedure calling semantics that L. In order to have proper column names in the result, provide arguments in L (which also follows L semantics. Similarly L, L, L and L affect the maximum number of rows returned as well as the ordering and grouping. Note that if select, count, ordered_by or grouped_by request parameters are present then these will override the values set on the class with select becoming bound by the select_exposes attribute. @@ -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; @@ -400,7 +393,7 @@ sub list_format_output foreach my $row ($rs->all) { - push(@$formatted, $self->row_format_output($row)); + push(@$formatted, $self->row_format_output($c, $row)); } $output->{$self->data_root} = $formatted; @@ -422,11 +415,15 @@ sub list_format_output =method_protected row_format_output -row_format_output is called each row of the inflated output generated from the search. It receives only one argument, the hashref that represents the row. By default, this method is merely a passthrough. +row_format_output is called each row of the inflated output generated from the search. It receives two arguments, the catalyst context and the hashref that represents the row. By default, this method is merely a passthrough. =cut -sub row_format_output { shift; shift; } # passthrough by default +sub row_format_output +{ + my ($self, $c, $row) = @_; + return $row; # passthrough by default +} =method_protected update_or_create @@ -438,7 +435,6 @@ 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) @@ -462,7 +458,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 +484,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 +511,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,7 +605,6 @@ 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) @@ -751,7 +743,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 +767,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];