Permalink
Browse files

Change initialization of Redis backend to correctly handle inclusion …

…or exclusion of a port number.
  • Loading branch information...
1 parent 65edc98 commit f71c2cc2d85bcd1e1f04eb6b880c52d42085e2b9 @bycoffe bycoffe committed with bradchoate Jan 27, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 django_kvstore/backends/redisdj.py
@@ -5,6 +5,8 @@
KEY_VALUE_STORE_BACKEND = 'redis://hostname:port'
+port is optional. If none is given, the port specified in redis.conf will be used.
+
"""
import base64
from base import BaseStorage, InvalidKeyValueStoreBackendError
@@ -23,8 +25,14 @@
class StorageClass(BaseStorage):
def __init__(self, server, params):
+ if ':' in server:
+ host, port = server.split(':')
+ port = int(port)
+ else:
+ host, port = server, None
+ params['port'] = port
BaseStorage.__init__(self, params)
- self._db = redis.Redis(host=server, **params)
+ self._db = redis.Redis(host=host, **params)
def set(self, key, value):
encoded = base64.encodestring(pickle.dumps(value, 2)).strip()

0 comments on commit f71c2cc

Please sign in to comment.