title: Can I save and load a heterogenous list of polymorphic types in MongoEngine?
body: <p>I want to save and load a heterogenous list of polymorphic types in MongoEngine.
  What I ideally want would look like:</p>
  
  <pre><code>from mongoengine import Document, EmbeddedDocument, IntField, StringField
  class BaseEmbedded(EmbeddedDocument):
      meta = {'abstract': True}
  class FooEmbedded(BaseEmbedded):
      an_int = IntField()
  class BarEmbedded(BaseEmbedded):
      a_string = StringField()
  class HasList(Document):
      heterogeneous_list = ListField(EmbeddedDocumentField(BaseEmbedded))
  has_list = HasList()
  has_list.heterogeneous_list = [FooEmbedded(an_int=3), BarEmbedded(a_string='bar')]
  has_list.save()
  HasList.objects(id=has_list.id)
  </code></pre>
  
  <p>The problem is that when saving an EmbeddedDocument, its specific polymorphic type is lost, so there's not enough data to reconstruct my original subclass:</p>
  
  <pre><code>[{"an_int":3}, {"a_string":"bar"}]
  </code></pre>
  
  <p>Unlike when saving a top-level Document, where the name of the specific class of the Document is the name of the collection in the DB.</p>
  
  <p>I could make <code>BaseEmbedded</code> a <code>DynamicEmbeddedDocument</code>, add a 'type' <code>StringField</code> with appropriate values for each subtype, and reconstruct the list element objects based on the type field.</p>
  
  <p>Is there a better solution I didn't think of?</p>