MrLoick / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

get_object_or_404 doesn't handle exceptions of the google db if None is provided for the key #217

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. call get_object_or_404 with any valid type of Model and with a None for 
key:
get_object_or_404(Event,None)

What is the expected output?  A 404 page.

What do you see instead? An exception.

What version of the product are you using? On what operating system?
1.1RC, Windows XP SP3 32bit

Please provide any additional information below.
I like the fact that the get_object_or_404 handles all that can go wrong 
for a given model or key. I would like the function to return a 404 for any 
invalid key values including None. Of course I could guard or catch the 
exception myself, but it wouldn't be as DRY. the db throw a BadArgumentError. I 
modified the get_object function and added an exception 
to the list of exceptions that cause the get_object function to return 
None. Maybe this behavior, should also be extended if the model class is 
None and to any other way to pass the key.

Original issue reported on code.google.com by sebastie...@gmail.com on 12 Sep 2009 at 9:38