# HG changeset patch # User Sverre Rabbelier # Date 1224545023 0 # Node ID 6af084bd290c0a1f68b6f458f786c6e2a19a9246 # Parent c2cbf8ebe1007517da1b866ccb4770a0a2109361 Improve the error message for getIfFields Patch by: Sverre Rabbelier Reviewed by: to-be-reviewed diff -r c2cbf8ebe100 -r 6af084bd290c app/soc/logic/models/base.py --- a/app/soc/logic/models/base.py Mon Oct 20 22:18:32 2008 +0000 +++ b/app/soc/logic/models/base.py Mon Oct 20 23:23:43 2008 +0000 @@ -98,12 +98,18 @@ fields = [] - for key, value in kwargs.iteritems(): - fields.extend('"%s" is "%s" ' % (key, value)) + msg = 'There is no %s where ' % self._name + + for index, pair in enumerate(kwargs.iteritems()): + if index != 0: + msg += ' and ' + + msg += '"%s" is "%s"' % pair + + msg += '.' # else: fields were supplied, but there is no Entity that has it - raise out_of_band.ErrorResponse( - 'There is no %s with %s.' % (self._name, ''.join(fields)), status=404) + raise out_of_band.ErrorResponse(msg, status=404) def getKeyNameForFields(self, **kwargs): """Return a Datastore key_name for a Entity from the specified fields.