j2labs/dictshield — Issue #30: Clarify that EmbeddedDocument can be a mixin with Document
Author: alexanderdean
Created: 2011-11-03 16:42:18+00:00
State: open

The examples on [embedded documents](https://github.com/j2labs/dictshield/blob/master/demos/embedded_documents.py) imply that a typical representation will inherit either from `Document` __or__ from `EmbeddedDocument`, depending on whether the item is a document itself or embedded within a larger document.

In fact in a RESTful API, every `Document` is typically also an `EmbeddedDocument` - because `GET "/orders/1"` yields an individual order `Document`, but `GET "/orders"` will return a list of all orders, which I can define like this in DictShield:

class OrderWrapper(Document):
orders = ListField(EmbeddedDocumentField(Order))

It turns out that it's fine in DictShield to define a representation as both a document and an embedded document, like this:

class Order(Document, EmbeddedDocument):

Maybe something should be added to the documentation to make it clear that it's possible to make a `Document` "embeddable" by mixing in `EmbeddedDocument`?