Change in vdsm[master]: janitorial: introduce the 'response' module

fromani at redhat.com fromani at redhat.com
Wed Mar 4 14:34:18 UTC 2015


Francesco Romani has posted comments on this change.

Change subject: janitorial: introduce the 'response' module
......................................................................


Patch Set 2:

(4 comments)

https://gerrit.ovirt.org/#/c/37912/2/lib/vdsm/response.py
File lib/vdsm/response.py:

Line 18: # Refer to the README and COPYING files for full details of the license
Line 19: #
Line 20: 
Line 21: 
Line 22: from vdsm.define import errCode
> In the next version it would be nice to move errCode here and call it ERROR
Indeed it would be nicer but that will result in a huge (albeit trivial) patch, because:

  $ git grep errCode | wc -l
209

(today's master). So, I'm looking for a way to do it in small(ish) steps. Or you mean to move it just here?
Line 23: 
Line 24: 
Line 25: def error(key, message=None):
Line 26:     if not message:


Line 21: 
Line 22: from vdsm.define import errCode
Line 23: 
Line 24: 
Line 25: def error(key, message=None):
> key is little too abstract, "name" makes this more clear that we get the er
will change
Line 26:     if not message:
Line 27:         return errCode[key]
Line 28:     else:
Line 29:         return {'status':


Line 23: 
Line 24: 
Line 25: def error(key, message=None):
Line 26:     if not message:
Line 27:         return errCode[key]
> Returning the mutable dict in errCode[key] is dangerous. The caller an modi
fair point. Noone should change that, but nothing guarantees that one never will, either. So, I'll fix that.
Line 28:     else:
Line 29:         return {'status':
Line 30:                 {'code': errCode[key]['status']['code'],


Line 27:         return errCode[key]
Line 28:     else:
Line 29:         return {'status':
Line 30:                 {'code': errCode[key]['status']['code'],
Line 31:                  'message': message}}
> So:
indeed nicer and simpler. Will use that (and I agree about errCode)


-- 
To view, visit https://gerrit.ovirt.org/37912
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ife293080c2c6654315a609478f3276c9008ea6e7
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list