Beispiel #1
0
    def serialize(self, w_obj):
        from hippy.module.serialize import SerializerMemo

        assert not isinstance(w_obj, W_Reference)
        builder = StringBuilder()
        w_obj.serialize(self, builder, SerializerMemo())
        return builder.build()
Beispiel #2
0
    def serialize(self, interp, w_ses):
        space = interp.space
        if not w_ses:
            return ""
        res = StringBuilder()
        memo = SerializerMemo()
        w_ses = w_ses.deref()
        with space.iter(w_ses.deref()) as itr:
            while not itr.done():
                w_key, w_value = itr.next_item(space)
                if space.is_integer(w_key):
                    num = space.int_w(w_key.as_number(space))
                    interp.notice("session_encode(): "
                                  "Skipping numeric key %d" % num)
                    continue
                key = space.str_w(w_key)

                if key.find('!') > 0:
                    continue
                res.append(key)
                res.append('|')
                w_value.serialize(space, res, memo)
        return res.build()