Commit 3bc99a61 authored by Vincent Pelletier's avatar Vincent Pelletier

Make it possible to disable compression for new stores.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2132 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 97f9a182
......@@ -34,10 +34,11 @@ class Storage(BaseStorage.BaseStorage,
__name__ = 'NEOStorage'
def __init__(self, master_nodes, name, connector=None, read_only=False,
**kw):
compress=True, **kw):
BaseStorage.BaseStorage.__init__(self, name)
self._is_read_only = read_only
self.app = Application(master_nodes, name, connector)
self.app = Application(master_nodes, name, connector,
compress=compress)
def load(self, oid, version=None):
try:
......
......@@ -122,7 +122,7 @@ class ThreadContext(object):
class Application(object):
"""The client node application."""
def __init__(self, master_nodes, name, connector=None, **kw):
def __init__(self, master_nodes, name, connector=None, compress=True, **kw):
# Start polling thread
self.em = EventManager()
self.poll_thread = ThreadedPoll(self.em)
......@@ -178,6 +178,7 @@ class Application(object):
lock = Lock()
self._nm_acquire = lock.acquire
self._nm_release = lock.release
self.compress = compress
@profiler_decorator
def _handlePacket(self, conn, packet, handler=None):
......@@ -572,12 +573,16 @@ class Application(object):
if data is None:
# this is a George Bailey object, stored as an empty string
data = ''
compressed_data = compress(data)
if len(compressed_data) > len(data):
if self.compress:
compressed_data = compress(data)
if len(compressed_data) > len(data):
compressed_data = data
compression = 0
else:
compression = 1
else:
compressed_data = data
compression = 0
else:
compression = 1
checksum = makeChecksum(compressed_data)
p = Packets.AskStoreObject(oid, serial, compression,
checksum, compressed_data, self.local_var.tid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment