Skip to content
This repository
Browse code

- added ability for subclasses of Redis to provide their own decode l…

…ogic if desired.

- setup.py needed to specify the package rather than py_module in order for build to work correctly.
  • Loading branch information...
commit 62fd846e4a6bf540400447e9be62982c22f412d8 1 parent 3b05b78
Andy McCurdy authored
6  redis/client.py
@@ -254,6 +254,8 @@ def parse_response(self, command_name, **options):
254 254
         response = self._parse_response(command_name)
255 255
         if command_name in self.RESPONSE_CALLBACKS:
256 256
             return self.RESPONSE_CALLBACKS[command_name](response, **options)
  257
+        elif isinstance(response, str):
  258
+            return self.decode(response)
257 259
         return response
258 260
         
259 261
     def encode(self, value):
@@ -265,6 +267,10 @@ def encode(self, value):
265 267
         # not a string or unicode, attempt to convert to a string
266 268
         return str(value)
267 269
         
  270
+    def decode(self, value):
  271
+        "Provides a hook for subclasses to add deserialization logic"
  272
+        return value
  273
+        
268 274
     def format_inline(self, *args, **options):
269 275
         "Formats a request with the inline protocol"
270 276
         cmd = '%s\r\n' % ' '.join([self.encode(a) for a in args])
2  setup.py
@@ -22,7 +22,7 @@
22 22
     'maintainer_email' : 'sedrik@gmail.com',
23 23
     'keywords' : ['Redis', 'key-value store'],
24 24
     'license' : 'MIT',
25  
-    'py_modules' : ['redis'],
  25
+    'packages' : ['redis'],
26 26
     'test_suite' : 'tests.all_tests',
27 27
     'classifiers' : [
28 28
         'Development Status :: 4 - Beta',

0 notes on commit 62fd846

Please sign in to comment.
Something went wrong with that request. Please try again.