Ejemplo n.º 1
0
#! /usr/bin/env python
import datetime
from pycouchbase import Document, Connection
from pycouchbase.fields import EmailField, PasswordField

Connection.auth("pycouchbase_samples", "pycouchbase")


class User(Document):
    __bucket_name__ = "pycouchbase_samples"
    doc_type = "user"
    structure = {
        "username": unicode,
        "email": EmailField,
        "password": PasswordField,
        "logins": {
            # datetime: ip
            datetime.datetime: unicode
        },
    }
Ejemplo n.º 2
0
 def setUp(self):
     self.local_connection = Connection.auth(server='localhost')
     self.author = Author()
Ejemplo n.º 3
0
#! /usr/bin/env python
import datetime
from pycouchbase import Document, Connection
from pycouchbase.fields import EmailField, ChoiceField
from example.samples.publisher import Publisher
from example.samples.book import Book

Connection.auth('pycouchbase_samples', 'pycouchbase')

class Gender(ChoiceField):
    CHOICES = {
        'M': 'Male',
        'F': 'Female',
    }


class Author(Document):
    __bucket_name__ = 'pycouchbase_samples'
    __key_field__ = 'slug' # optional
    doc_type = 'author'
    structure = {
        'slug': unicode,
        'first_name': unicode,
        'last_name': unicode,
        'gender': Gender,
        'email': EmailField,
        'publisher': Publisher, # kind of foreign key
        'books': [Book], # 1-to-many, or many-to-many? some-to-some.. :)
        'has_book': bool,
        'age': int,
        'birthday': datetime.date,