예제 #1
0
def server_decode(msg):
    """Decodes msg and returns its parts"""
    unpickler = Unpickler(BytesIO(msg))
    unpickler.find_global = server_find_global

    try:
        return unpickler.load() # msgid, flags, name, args
    except:
        log("can't decode message: %s" % short_repr(msg),
            level=logging.ERROR)
        raise
예제 #2
0
def decode(msg):
    """Decodes msg and returns its parts"""
    unpickler = Unpickler(BytesIO(msg))
    unpickler.find_global = find_global
    try:
        unpickler.find_class = find_global  # PyPy, zodbpickle, the non-c-accelerated version
    except AttributeError:
        pass
    try:
        return unpickler.load()  # msgid, flags, name, args
    except:
        log("can't decode message: %s" % short_repr(msg), level=logging.ERROR)
        raise
예제 #3
0
def decode(msg):
    """Decodes msg and returns its parts"""
    unpickler = Unpickler(BytesIO(msg))
    unpickler.find_global = find_global
    try:
        unpickler.find_class = find_global # PyPy, zodbpickle, the non-c-accelerated version
    except AttributeError:
        pass
    try:
        return unpickler.load() # msgid, flags, name, args
    except:
        log("can't decode message: %s" % short_repr(msg),
            level=logging.ERROR)
        raise
예제 #4
0
    def __iter__(self):
        self.file.seek(0)
        unpickler = Unpickler(self.file)
        server_resolved = self.server_resolved
        client_resolved = self.client_resolved

        # Gaaaa, this is awkward. There can be entries in serials that
        # aren't in the buffer, because undo.  Entries can be repeated
        # in the buffer, because ZODB. (Maybe this is a bug now, but
        # it may be a feature later.

        seen = set()
        for i in range(self.count):
            oid, data = unpickler.load()
            if client_resolved.get(oid, i) == i:
                seen.add(oid)
                yield oid, data, oid in server_resolved

        # We may have leftover oids because undo
        for oid in server_resolved:
            if oid not in seen:
                yield oid, None, True
예제 #5
0
    def __iter__(self):
        self.file.seek(0)
        unpickler = Unpickler(self.file)
        server_resolved = self.server_resolved
        client_resolved = self.client_resolved

        # Gaaaa, this is awkward. There can be entries in serials that
        # aren't in the buffer, because undo.  Entries can be repeated
        # in the buffer, because ZODB. (Maybe this is a bug now, but
        # it may be a feature later.

        seen = set()
        for i in range(self.count):
            oid, data = unpickler.load()
            if client_resolved.get(oid, i) == i:
                seen.add(oid)
                yield oid, data, oid in server_resolved

        # We may have leftover oids because undo
        for oid in server_resolved:
            if oid not in seen:
                yield oid, None, True
예제 #6
0
class TBIterator(object):
    def __init__(self, f, count):
        self.file = f
        self.count = count
        self.unpickler = Unpickler(f)

    def __iter__(self):
        return self

    def __next__(self):
        """Return next tuple of data or None if EOF"""
        if self.count == 0:
            self.file.seek(0)
            self.size = 0
            raise StopIteration
        oid_ver_data = self.unpickler.load()
        self.count -= 1
        return oid_ver_data

    next = __next__
예제 #7
0
class TBIterator(object):

    def __init__(self, f, count):
        self.file = f
        self.count = count
        self.unpickler = Unpickler(f)

    def __iter__(self):
        return self

    def __next__(self):
        """Return next tuple of data or None if EOF"""
        if self.count == 0:
            self.file.seek(0)
            self.size = 0
            raise StopIteration
        oid_ver_data = self.unpickler.load()
        self.count -= 1
        return oid_ver_data
    next = __next__
예제 #8
0
 def __iter__(self):
     self.file.seek(0)
     unpickler = Unpickler(self.file)
     for i in range(self.stores):
         yield unpickler.load()
예제 #9
0
 def __init__(self, f, count):
     self.file = f
     self.count = count
     self.unpickler = Unpickler(f)
예제 #10
0
 def __init__(self, f, count):
     self.file = f
     self.count = count
     self.unpickler = Unpickler(f)