Codebase list libmagpie-perl / dbaead1
Some minor cleanup pending next release. Kip Hampton 11 years ago
4 changed file(s) with 15 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
241241
242242 sub DELETE {
243243 my $self = shift;
244 my $ctxt = shift;
244245 $self->parent_handler->resource( $self );
245246 my $req = $self->request;
246247
251252 return OK;
252253 }
253254
254 my @steps = split '/', $path;
255
256 my $id = $req->param('id') || pop @steps;
255 my $id = $self->get_entity_id($ctxt);
257256
258257 # should we do a separate lookup to make sure the data is there?
259258 try {
269268 $self->response->status(204);
270269 return OK;
271270 }
271
272272
273273 sub PUT {
274274 my $self = shift;
319319 return DONE;
320320 }
321321
322
323322 foreach my $key (keys(%args)) {
324323 $existing->$key( $args{$key} );
325324 }
326325
327 try {
328 $self->data_source->store($existing);
326
327 try {
328 $self->data_source->txn_do(sub {
329 my $scope = $self->data_source->new_scope;
330 $self->data_source->store($existing);
331 });
329332 }
330333 catch {
331334 my $error = "Error updating data entity with ID $existing_id: $_\n";
332335 $self->set_error( { status_code => 500, reason => $error } );
333336 };
334337
338 warn "should be stored";
335339 return OK if $self->has_error;
336340
337341 # finally, if it all went OK, say so.
161161 }
162162
163163 my $matcher_class = $self->matcher_class || 'Magpie::Matcher';
164
164
165165 try {
166166 Plack::Util::load_class($matcher_class);
167167 }
178178 );
179179
180180 $pipeline = $matcher->construct_pipeline($pipeline);
181
181
182182 if ($self->debug) {
183183 Plack::Util::load_class('Data::Dumper::Concise');
184184 my $message = 'PIPELINE: ' . Data::Dumper::Concise::Dumper($pipeline);
185 #warn 'STACK ' . Data::Dumper::Concise::Dumper(\@STACK);
185186 warn $message . "\n";
186187 $req->logger({ level => 'debug', message => $message, });
187 }
188 }
188189
189190 my $m = Magpie::Machine->new( plack_request => $req, );
190191
3030 done_testing();
3131 __END__
3232
33 # these are added by the Handler classes:
34 ok( $m->assets->has_service('othervar'), 'asset added in handler.' );
35
36 my $other = $m->resolve_asset( service => 'othervar' );
37
38 is( $other, 'other value', 'correct value passed');
39
40 # check a few common internals
41 my $resource = $m->resolve_internal_asset( service => 'default_resource' );
42 ok( $resource );
43 isa_ok($resource, 'Magpie::Resource::Abstract');
44
45 done_testing();
2626 }
2727 {
2828 my $res = $cb->(GET "http://localhost/api/widget/aabbccdd/part/OU812");
29 like $res->content, qr|pathmadness__long_path::widget_pathmadness__part_id::OU812__widget_id::aabbccdd_|;
29 like $res->content, qr|pathmadness__part_id::OU812__widget_id::aabbccdd_|;
3030 }
3131
3232 };