On 27/07/2012 22:21, Iain Duncan wrote:
Hi, I'm implementing a set of views to return json to work with Dojo
object stores. From what I can gather, Dojo best wants me to return a
204 status after a successful delete.
The view is registered as using the json renderer. It changes the
response status to 204 and returns None to the json renderer (or an
empty dict, I've tried both). Web test however is throwing an assertion
error with the message that there is content with my 204 response.
Try to return pyramid.httpexceptions.HTTPNoContent()
The call in my webtest test:
res = self.app.delete('/json/person/%i' % item.id <http://item.id>,
status=204)
The view code that I hoped would work:
class JsonItemDeleteView(JsonView):
def __call__(self):
try:
self.model.delete_obj(self.context)
self.request.response.status = '204 No Content'
# status 204 means there should be *no* response body
return None
except Exception, e:
log.info <http://log.info>("Error deleting %s, %s" % (self.context, e) )
json_dict = {}
self.request.response.status = '500 Internal Server Error'
json_dict['error'] = 'Error: The item was not able to be
deleted'
return json_dict
Traceback:
File
"/home/xornot/trunk/DojoSkunk/eggs/WebTest-1.3.4-py2.7.egg/webtest/lint.py",
line 443, in check_content_type
"which must not return content.") % code)
AssertionError: Content-Type header found in a 204 response, which must
not return content.
Any help greatly appreciated!
iain
--
You received this message because you are subscribed to the Google
Groups "pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.