Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- 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
@andymccurdy authored
Showing with 7 additions and 1 deletion.
  1. +6 −0 redis/client.py
  2. +1 −1  setup.py
View
6 redis/client.py
@@ -254,6 +254,8 @@ def parse_response(self, command_name, **options):
response = self._parse_response(command_name)
if command_name in self.RESPONSE_CALLBACKS:
return self.RESPONSE_CALLBACKS[command_name](response, **options)
+ elif isinstance(response, str):
+ return self.decode(response)
return response
def encode(self, value):
@@ -265,6 +267,10 @@ def encode(self, value):
# not a string or unicode, attempt to convert to a string
return str(value)
+ def decode(self, value):
+ "Provides a hook for subclasses to add deserialization logic"
+ return value
+
def format_inline(self, *args, **options):
"Formats a request with the inline protocol"
cmd = '%s\r\n' % ' '.join([self.encode(a) for a in args])
View
2  setup.py
@@ -22,7 +22,7 @@
'maintainer_email' : 'sedrik@gmail.com',
'keywords' : ['Redis', 'key-value store'],
'license' : 'MIT',
- 'py_modules' : ['redis'],
+ 'packages' : ['redis'],
'test_suite' : 'tests.all_tests',
'classifiers' : [
'Development Status :: 4 - Beta',
Please sign in to comment.
Something went wrong with that request. Please try again.