Fix bug where serialization_format is ignored
Change-Id: I5a5ac8b5f18e077105ab12e9b1f0ccafac3983f7
This commit is contained in:
parent
411c7cb8ff
commit
c97fb37e10
@ -52,6 +52,8 @@ class MemcacheMiddleware(object):
|
|||||||
self.memcache_servers = '127.0.0.1:11211'
|
self.memcache_servers = '127.0.0.1:11211'
|
||||||
if serialization_format is None:
|
if serialization_format is None:
|
||||||
serialization_format = 2
|
serialization_format = 2
|
||||||
|
else:
|
||||||
|
serialization_format = int(serialization_format)
|
||||||
|
|
||||||
self.memcache = MemcacheRing(
|
self.memcache = MemcacheRing(
|
||||||
[s.strip() for s in self.memcache_servers.split(',') if s.strip()],
|
[s.strip() for s in self.memcache_servers.split(',') if s.strip()],
|
||||||
|
@ -48,7 +48,7 @@ class SetConfigParser(object):
|
|||||||
if option == 'memcache_servers':
|
if option == 'memcache_servers':
|
||||||
return '1.2.3.4:5'
|
return '1.2.3.4:5'
|
||||||
elif option == 'memcache_serialization_support':
|
elif option == 'memcache_serialization_support':
|
||||||
return '2'
|
return '1'
|
||||||
else:
|
else:
|
||||||
raise NoOptionError(option)
|
raise NoOptionError(option)
|
||||||
else:
|
else:
|
||||||
@ -104,6 +104,8 @@ class TestCacheMiddleware(unittest.TestCase):
|
|||||||
finally:
|
finally:
|
||||||
memcache.ConfigParser = orig_parser
|
memcache.ConfigParser = orig_parser
|
||||||
self.assertEquals(app.memcache_servers, '127.0.0.1:11211')
|
self.assertEquals(app.memcache_servers, '127.0.0.1:11211')
|
||||||
|
self.assertEquals(app.memcache._allow_pickle, False)
|
||||||
|
self.assertEquals(app.memcache._allow_unpickle, False)
|
||||||
|
|
||||||
def test_conf_from_extra_conf(self):
|
def test_conf_from_extra_conf(self):
|
||||||
orig_parser = memcache.ConfigParser
|
orig_parser = memcache.ConfigParser
|
||||||
@ -113,16 +115,22 @@ class TestCacheMiddleware(unittest.TestCase):
|
|||||||
finally:
|
finally:
|
||||||
memcache.ConfigParser = orig_parser
|
memcache.ConfigParser = orig_parser
|
||||||
self.assertEquals(app.memcache_servers, '1.2.3.4:5')
|
self.assertEquals(app.memcache_servers, '1.2.3.4:5')
|
||||||
|
self.assertEquals(app.memcache._allow_pickle, False)
|
||||||
|
self.assertEquals(app.memcache._allow_unpickle, True)
|
||||||
|
|
||||||
def test_conf_from_inline_conf(self):
|
def test_conf_from_inline_conf(self):
|
||||||
orig_parser = memcache.ConfigParser
|
orig_parser = memcache.ConfigParser
|
||||||
memcache.ConfigParser = SetConfigParser
|
memcache.ConfigParser = SetConfigParser
|
||||||
try:
|
try:
|
||||||
app = memcache.MemcacheMiddleware(
|
app = memcache.MemcacheMiddleware(
|
||||||
FakeApp(), {'memcache_servers': '6.7.8.9:10'})
|
FakeApp(),
|
||||||
|
{'memcache_servers': '6.7.8.9:10',
|
||||||
|
'serialization_format': '0'})
|
||||||
finally:
|
finally:
|
||||||
memcache.ConfigParser = orig_parser
|
memcache.ConfigParser = orig_parser
|
||||||
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
|
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
|
||||||
|
self.assertEquals(app.memcache._allow_pickle, False)
|
||||||
|
self.assertEquals(app.memcache._allow_unpickle, True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user