2010/5/10 David Knowles <dknow...@google.com>:
>>
>> +_JSON_ENCODER = simplejson.JSONEncoder(sort_keys=True)
>> +
>>
>
> This is not a constant, so it shouldn't be in ALL_CAPS.  I would also prefer
> to see this as an attribute of the class.
>

Done, interdiff:

--- a/lib/rapi/client.py
+++ b/lib/rapi/client.py
@@ -55,8 +55,6 @@ VALID_NODE_ROLES = frozenset([
   ])
 VALID_STORAGE_TYPES = frozenset(["file", "lvm-pv", "lvm-vg"])

-_JSON_ENCODER = simplejson.JSONEncoder(sort_keys=True)
-

 class Error(Exception):
   """Base error class for this module.
@@ -308,6 +306,7 @@ class GanetiRapiClient(object):

   """
   USER_AGENT = "Ganeti RAPI Client"
+  _json_encoder = simplejson.JSONEncoder(sort_keys=True)

   def __init__(self, host, port=GANETI_RAPI_PORT,
                username=None, password=None,
@@ -398,7 +397,7 @@ class GanetiRapiClient(object):

     """
     if content:
-      encoded_content = _JSON_ENCODER.encode(content)
+      encoded_content = self._json_encoder.encode(content)
     else:
       encoded_content = None

Reply via email to