get_stream: Use try/except

For consistency with the rest of our code.

(imported from commit a2df17facad1a4e3b9e5e1dc4d33b64010cee939)
This commit is contained in:
Keegan McAllister 2012-11-01 15:28:44 -04:00
parent 8df247708c
commit f2ac76aeac
1 changed files with 3 additions and 4 deletions

View File

@ -84,10 +84,9 @@ def json_error(msg, data={}, status=400):
return json_response(res_type="error", msg=msg, data=data, status=status)
def get_stream(stream_name, realm):
stream = Stream.objects.filter(name__iexact=stream_name, realm=realm)
if stream:
return stream[0]
else:
try:
return Stream.objects.get(name__iexact=stream_name, realm=realm)
except Stream.DoesNotExist:
return None
@require_post