def decompress_string(value):
 try:
  val = value.encode('utf').decode('base64')
  zbuf = cStringIO.StringIO(val)
  zfile = gzip.GzipFile(fileobj=zbuf)
  ret = zfile.read()
  zfile.close()
 except Exception as e:
  logger.error('String decompression failed. There may be corrupted data in the database: %s', e)
  ret = value
 return ret

def decompress_string ( value ) : try : val = value . encode ( 'utf' ) . decode ( 'base64' ) zbuf = cStringIO . StringIO ( val ) zfile = gzip . GzipFile ( fileobj = zbuf ) ret = zfile . read ( ) zfile . close ( ) except Exception as e : logger . error ( 'String decompression failed. There may be corrupted data in the database: %s' , e ) ret = value return ret
helper function to reverse compressedtextfield .