Exemplo n.º 1
0
    "ResponseHeader",
    (
        "magic",
        "opcode", 
        "key_len",
        "extra_len",
        "data_type",
        "status",
        "body_len",
        "opaque",
        "cas"
    ),
    "!BBHBBHI4s8s"
)

Request = structure("Request", ("header", "extra", "key", "value"))
Response = structure("Response", ("request", "header", "extra", "key", "value"))

status_reason = {
    0x0000 : "no error",
    0x0001 : "key not found",
    0x0002 : "key exist",
    0x0003 : "value too large",
    0x0004 : "invalid arguments",
    0x0005 : "item not stored",
    0x0006 : "incr/decr on non-numeric value",
    0x0007 : "the vbucket belong to another server",
    0x0008 : "authentification error",
    0x0009 : "authentification continue",
    0x0020 : "authentification required / not successful",
    0x0021 : "further authentification step required",
Exemplo n.º 2
0
Arquivo: bucket.py Projeto: NoZip/uzu
from uuid import uuid4
from collections.abc import Sequence, Mapping
from datetime import datetime

from tornado.gen import coroutine

from uzu.db.driver import Driver
from uzu.tools.memcached import Memcached
from uzu.tools.structure import structure
from uzu.db.field import *

from uzu.db.driver.couchbase.design import Design


Meta = structure("Meta", ("key", "cas"))

ISO_DATE = "%Y-%m-%d"
ISO_TIME = "%H:%M:%S.%f%z"
ISO_DATETIME = ISO_DATE + 'T' + ISO_TIME

def encode_field(value, field):
    if isinstance(field, DateTimeField):
        return value.strftime(ISO_DATETIME)

    elif isinstance(field, ListField):
        return [encode_field(item, field.field) for item in value]
        
    elif isinstance(field, ForeignKeyField):
        return value.key