@staticmethod
    def deserialize(buffer, decode='pickle'):
        """This method is used only by the Journal service to reconstruct 
           serialized objects by calling the custom ``construct(state)`` 
           method of their class.

           @param buffer (a ``.read()``-supporting file-like object)
           @param decode (str) <pickle|json> default='pickle'

           @raise AssertionError
           @return Entity instance
        """
        state = None
        if decode == 'pickle':
            state = _pickle.load(buffer)
        elif decode == 'json' and _json:
            state = _json.load(buffer)
        if isinstance(state, type(None)):
            raise AssertionError('state not deserialized') #nothing decoded
        try:
            module = __import__(state['__module__'], fromlist=[state['__class__']])
        except __HOLE__:
            #python2.4 __import__ implementation doesn't accept **kwargs
            module = __import__(state['__module__'], {}, {}, [state['__class__']])
        myClass = getattr(module, state['__class__'])
        return myClass.construct(state)
dataset/ETHPy150Open OrbitzWorldwide/droned/romeo/lib/romeo/entity.py/Entity.deserialize