diff options
author | andymccurdy <andy@andymccurdy.com> | 2010-02-16 13:07:50 -0800 |
---|---|---|
committer | andymccurdy <andy@andymccurdy.com> | 2010-02-16 13:07:50 -0800 |
commit | 62fd846e4a6bf540400447e9be62982c22f412d8 (patch) | |
tree | 9130d365bcefbf8f4e5d411a27c743d04f0be5dc /redis/client.py | |
parent | 3b05b78c0af9ed92131e797d666f0a1e9d20ff92 (diff) | |
download | redis-py-62fd846e4a6bf540400447e9be62982c22f412d8.tar.gz |
- added ability for subclasses of Redis to provide their own decode logic if desired.
- setup.py needed to specify the package rather than py_module in order for build to work correctly.
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py index f97bc88..d16250a 100644 --- a/redis/client.py +++ b/redis/client.py @@ -254,6 +254,8 @@ class Redis(object): 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 @@ class Redis(object): # 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]) |