Ejemplo n.º 1
0
def _json_encode_wrapper(*args):
    return json.dumps(*args, ensure_ascii=False)


class FMT_AUTO_object_not_a_number(object):
    pass


# TODO: Make this more readable and have PEP8 ignore it.
_FMT_AUTO = FMT_AUTO_object_not_a_number()

C._init_helpers(result_reprfunc=_result__repr__,
                fmt_utf8_flags=C.FMT_UTF8,
                fmt_bytes_flags=C.FMT_BYTES,
                fmt_json_flags=C.FMT_JSON,
                fmt_pickle_flags=C.FMT_PICKLE,
                pickle_encode=pickle.dumps,
                pickle_decode=pickle.loads,
                json_encode=_json_encode_wrapper,
                json_decode=json.loads,
                lcb_errno_map=E._LCB_ERRNO_MAP,
                misc_errno_map=E._EXCTYPE_MAP,
                default_exception=E.CouchbaseError,
                obsinfo_reprfunc=_observeinfo__repr__,
                itmcoll_base_type=ItemCollection,
                itmopts_dict_type=ItemOptionDict,
                itmopts_seq_type=ItemSequence,
                fmt_auto=_FMT_AUTO)

C.FMT_AUTO = _FMT_AUTO
Ejemplo n.º 2
0
    if flags & C.PYCBC_RESFLD_CAS and hasattr(self, 'cas'):
        details.append("CAS=0x{cas:x}".format(cas=self.cas))

    if flags & C.PYCBC_RESFLD_CAS and hasattr(self, 'flags'):
        details.append("Flags=0x{flags:x}".format(flags=self.flags))

    if flags & C.PYCBC_RESFLD_HTCODE and hasattr(self, "http_status"):
        details.append("HTTP={0}".format(self.http_status))

    if flags & C.PYCBC_RESFLD_URL and hasattr(self, "url"):
        details.append("URL={0}".format(self.url))

    ret = "{0}<{1}>".format(self.__class__.__name__, ', '.join(details))
    return ret

def _json_encode_wrapper(*args):
    return json.dumps(*args, ensure_ascii=False)

C._init_helpers(
                result_reprfunc = _result__repr__,
                fmt_utf8_flags = C.FMT_UTF8,
                fmt_bytes_flags = C.FMT_BYTES,
                pickle_encode = pickle.dumps,
                pickle_decode = pickle.loads,
                json_encode = _json_encode_wrapper,
                json_decode = json.loads,
                lcb_errno_map = E._LCB_ERRNO_MAP,
                misc_errno_map = E._EXCTYPE_MAP,
                default_exception = E.CouchbaseError)
def _json_encode_wrapper(*args):
    return json.dumps(*args, ensure_ascii=False)


class FMT_AUTO_object_not_a_number(object):
    pass

# TODO: Make this more readable and have PEP8 ignore it.
_FMT_AUTO = FMT_AUTO_object_not_a_number()

C._init_helpers(result_reprfunc=_result__repr__,
                fmt_utf8_flags=C.FMT_UTF8,
                fmt_bytes_flags=C.FMT_BYTES,
                fmt_json_flags=C.FMT_JSON,
                fmt_pickle_flags=C.FMT_PICKLE,
                pickle_encode=pickle.dumps,
                pickle_decode=pickle.loads,
                json_encode=_json_encode_wrapper,
                json_decode=json.loads,
                lcb_errno_map=E._LCB_ERRNO_MAP,
                misc_errno_map=E._EXCTYPE_MAP,
                default_exception=E.CouchbaseError,
                obsinfo_reprfunc=_observeinfo__repr__,
                itmcoll_base_type=ItemCollection,
                itmopts_dict_type=ItemOptionDict,
                itmopts_seq_type=ItemSequence,
                fmt_auto=_FMT_AUTO)

C.FMT_AUTO = _FMT_AUTO
Ejemplo n.º 4
0
            break

    fmstr = ("{cls}<Status=[{status_s} (0x{flags:X})], "
             "Master={is_master}, "
             "CAS=0x{cas:X}>")
    ret = fmstr.format(cls=self.__class__.__name__,
                       status_s=flag_str,
                       flags=self.flags,
                       is_master=bool(self.from_master),
                       cas=self.cas)
    return ret


def _json_encode_wrapper(*args):
    return json.dumps(*args, ensure_ascii=False)


# TODO: Make this more readable and have PEP8 ignore it.

C._init_helpers(result_reprfunc=_result__repr__,
                fmt_utf8_flags=C.FMT_UTF8,
                fmt_bytes_flags=C.FMT_BYTES,
                pickle_encode=pickle.dumps,
                pickle_decode=pickle.loads,
                json_encode=_json_encode_wrapper,
                json_decode=json.loads,
                lcb_errno_map=E._LCB_ERRNO_MAP,
                misc_errno_map=E._EXCTYPE_MAP,
                default_exception=E.CouchbaseError,
                obsinfo_reprfunc=_observeinfo__repr__)