Package couchdb :: Module schema :: Class DictField

Class DictField



object --+    
         |    
     Field --+
             |
            DictField

Field type for nested dictionaries.

>>> from couchdb import Server
>>> server = Server('http://localhost:5984/')
>>> db = server.create('python-tests')
>>> class Post(Document):
...     title = TextField()
...     content = TextField()
...     author = DictField(Schema.build(
...         name = TextField(),
...         email = TextField()
...     ))
>>> post = Post(title='Foo bar', author=dict(name='John Doe',
...                                          email='john@doe.com'))
>>> post.store(db) #doctest: +ELLIPSIS
<Post ...>
>>> post = Post.load(db, post.id)
>>> post.author.name
u'John Doe'
>>> post.author.email
u'john@doe.com'
>>> del server['python-tests']


Instance Methods
 
__init__(self, schema, name=None, default=None)

Inherited from Field: __get__, __set__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, schema, name=None, default=None)
(Constructor)

 
Overrides: Field.__init__