Skip to content

Instantly share code, notes, and snippets.

@millerdev
Created November 12, 2015 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save millerdev/d394c98be89140457713 to your computer and use it in GitHub Desktop.
Save millerdev/d394c98be89140457713 to your computer and use it in GitHub Desktop.
from dimagi.ext.couchdbkit import (
Document,
DocumentSchema,
DictProperty,
IntegerProperty,
StringProperty,
)
class BlobMeta(DocumentSchema):
content_type = StringProperty()
content_length = IntegerProperty()
class AttachmentsMixin(object):
blobs = DictProperty(BlobMeta)
class RealDocument(AttachmentsMixin, Document):
doc_type = "RealDocument"
doc = RealDocument()
doc.blobs = {}
# TypeError: attribute name must be string, not 'NoneType'
doc.blobs["key"] = BlobMeta()
# AssertionError
doc2 = RealDocument(blobs={})
# TypeError: attribute name must be string, not 'NoneType'
# how to set doc.blobs?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment