Improve the error message for getIfFields
authorSverre Rabbelier <srabbelier@gmail.com>
Mon, 20 Oct 2008 23:23:43 +0000
changeset 396 6af084bd290c
parent 395 c2cbf8ebe100
child 397 fbb59a59c075
Improve the error message for getIfFields Patch by: Sverre Rabbelier Reviewed by: to-be-reviewed
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.