Home | Trees | Indices | Help |
---|
|
object --+ | properties.Property --+ | SchemaProperty
Schema property. It allows you add a DocumentSchema instance a member of a Document object. It returns a `schemaDocumentSchema` object. Exemple : >>> from couchdbkit import * >>> class Blog(DocumentSchema): ... title = StringProperty() ... author = StringProperty(default="me") ... >>> class Entry(Document): ... title = StringProperty() ... body = StringProperty() ... blog = SchemaProperty(Blog()) ... >>> test = Entry() >>> test._doc {'body': None, 'doc_type': 'Entry', 'title': None, 'blog': {'doc_type': 'Blog', 'author': u'me', 'title': None}} >>> test.blog.title = "Mon Blog" >>> test._doc {'body': None, 'doc_type': 'Entry', 'title': None, 'blog': {'doc_type': 'Blog', 'author': u'me', 'title': u'Mon Blog'}} >>> test.blog.title u'Mon Blog' >>> from couchdbkit import Server >>> s = Server() >>> db = s.create_db('couchdbkit_test') >>> Entry._db = db >>> test.save() >>> doc = Entry.objects.get(test.id) >>> doc.blog.title u'Mon Blog' >>> del s['simplecouchdb_test']
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from |
|
|||
Inherited from |
|
|||
Inherited from |
|
Default constructor for a property. :param verbose_name: str, verbose name of field, could be use for description :param name: str, name of field :param default: default value :param required: True if field is required, default is False :param validators: list of callable or callable, field validators function that are executed when document is saved.
|
return default value
|
test if value is empty
|
validate value
|
convert to python type
|
convert to json, Converted value is saved in couchdb.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri May 4 11:48:41 2012 | http://epydoc.sourceforge.net |