__init__.py
changeset 10602 4845012cfc8e
parent 10272 3231fd2fa7a5
child 10616 f454404733c1
equal deleted inserted replaced
10601:73c1c9cf6bda 10602:4845012cfc8e
    20 """
    20 """
    21 __docformat__ = "restructuredtext en"
    21 __docformat__ = "restructuredtext en"
    22 
    22 
    23 # ignore the pygments UserWarnings
    23 # ignore the pygments UserWarnings
    24 import warnings
    24 import warnings
    25 import cPickle
       
    26 import zlib
    25 import zlib
    27 warnings.filterwarnings('ignore', category=UserWarning,
    26 warnings.filterwarnings('ignore', category=UserWarning,
    28                         message='.*was already imported',
    27                         message='.*was already imported',
    29                         module='.*pygments')
    28                         module='.*pygments')
    30 
    29 
    37 
    36 
    38 CW_SOFTWARE_ROOT = __path__[0]
    37 CW_SOFTWARE_ROOT = __path__[0]
    39 
    38 
    40 import sys, os, logging
    39 import sys, os, logging
    41 from StringIO import StringIO
    40 from StringIO import StringIO
       
    41 
       
    42 from six.moves import cPickle as pickle
    42 
    43 
    43 from logilab.common.deprecation import deprecated
    44 from logilab.common.deprecation import deprecated
    44 from logilab.common.logging_ext import set_log_methods
    45 from logilab.common.logging_ext import set_log_methods
    45 from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS
    46 from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS
    46 
    47 
   130 
   131 
   131     @classmethod
   132     @classmethod
   132     def zpickle(cls, obj):
   133     def zpickle(cls, obj):
   133         """ return a Binary containing a gzipped pickle of obj """
   134         """ return a Binary containing a gzipped pickle of obj """
   134         retval = cls()
   135         retval = cls()
   135         retval.write(zlib.compress(cPickle.dumps(obj, protocol=2)))
   136         retval.write(zlib.compress(pickle.dumps(obj, protocol=2)))
   136         return retval
   137         return retval
   137 
   138 
   138     def unzpickle(self):
   139     def unzpickle(self):
   139         """ decompress and loads the stream before returning it """
   140         """ decompress and loads the stream before returning it """
   140         return cPickle.loads(zlib.decompress(self.getvalue()))
   141         return pickle.loads(zlib.decompress(self.getvalue()))
   141 
   142 
   142 
   143 
   143 def check_password(eschema, value):
   144 def check_password(eschema, value):
   144     return isinstance(value, (str, Binary))
   145     return isinstance(value, (str, Binary))
   145 BASE_CHECKERS['Password'] = check_password
   146 BASE_CHECKERS['Password'] = check_password