I have a CRUD interface to an application. This is used for both the Web and directly as an API.
The model uses DBIC which, as you know, allows chaining resultsets, which I use to add additional constraints to the result set. So, a request for, say, /user/1234 might result in: $c->model( 'App::User' )->search( { 'me.id' => $requested_user_id, 'me.active => 1, 'me.date_expires' => [ { '>' => \'now()' }, # past expired { '=' => undef }, # or never expires ], 'account.active' => 1, 'account.balance' => { '>' => 0 }, 'account.locked' => 0, 'account.date_expires' => [ { '>' => \'now()' }, # past expired { '=' => undef }, # or never expires ], }, { join => 'account', }, ); [That's not a great example because we assume that "user" and "account" might get checked when first logging in. Ignore that. Just assume a query that does a lot of joins to test if a given object can be accessed.] The request either succeeds (200) or fails (404). The VAST majority of the time the ID provided will return a row because a valid ID was provided by the application itself in the first place. But, for a tiny, tiny percent a request might fail. Then the question is *why* did it fail? What WHERE condition or join failed? Just like our favorite topic premature optimization, I don't think it would be wise to write the above in multiple stages (and multiple requests to the database) just to check each step for something that almost never fails. On the other hand, it's not unreasonable for an API request to return a reason why something failed. Sure would make tech support's life easier. So, what would you recommend? Have a separate /user/$id/debug method that does a separate step-by-step of the business logic? Scrap all that really handy chaining of resultsets that works so well with Catalyst's chained actions? -- Bill Moseley mose...@hank.org
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/