s-kostyuk / everpl

The Everthing Platfrom source code
https://everpl.readthedocs.io/
MIT License
0 stars 1 forks source link

Safe fetching for things and placements #5

Open s-kostyuk opened 7 years ago

s-kostyuk commented 7 years ago

A version of fetchers for Things and Placements that doesn't raise an exception if corresponding was not found by the specified ID. They return 'default' argument value instead of it (instead of raising exception).

This approach has upsides and downsides. As upside, it will work faster for handling of requests for non-existing data. As a downside, handling of requests for existing data objects is slightly slower.

s-kostyuk commented 7 years ago

It looks like Django uses try-catch approach for non-existing objects: one, two. If object can't be fetched, than ObjectDoesNotExist exception is raised. Than this exception is caught in some sort of router / root handler / etc. and is processed by a registered 404 request handler.