If you've got a resource that handles GET and DELETE and has one or more
representations that require a certain amount of effort to instantiate, but
might 404 based on information out of the database, what's the usual pattern to
handle this?

On the one end of the spectrum, I could create both representations in the
constructor, but this create performance load when it might simply be a DELETE
call that doesn't need either representation directly.  

On the other, I could hold off from touching the database until such time as I'm
in delete() or getRepresentation(Variant); but I'm not sure if I can 404 from
these.  This seems like the performant approach, but I'm not sure if fits with
the way Restlet is designed.

Then, in the middle somewhere, I could verify the record exists for GET or
DELETE in the constructor, put in the variants, and then handle delete() and
getRepresentation(Variant) through another call to the database.  This requires
me to make two calls (or hold a database connection / recordset / session open
between the two).

Reply via email to