First, let me put this into context. We are currently using mongokit
to develop a python web-based application that stores its data in
Mongo. We use Mongo because:
1) it allows to store potentially deeply nested documents
2) JSON format is easily usable in web applications
We have data structures in this project which are extremely similar to
what documents are (i.e., JSON structures), but are not tied to a
particular collection, and can be embedded in multiple documents. This
is really important in our case, because if we were to reference these
structure as mere Document objects the number and nesting degree of
the embedded documents would mean that the retrieval of a single
document would require many mongo requests instead of one.
What we have done is we forked the mongokit project
(https://github.com/mobyle2/mongokit) to test the feasability of the
following modification:
- create embedded documents as SchemaDocument subclasses,
- ensure their type is correctly re-instanciated when querying data
from Mongo (this is using a mechanism quite similar to the use of
"_type" field for "inherited queries"
(https://github.com/namlook/mongokit/wiki/Inherited-queries).