MongoEngine / eve-mongoengine

An Eve extension for MongoEngine ODM support
Other
39 stars 28 forks source link

Set default query manager attribute into datalayer class #9

Closed hellerstanislav closed 10 years ago

hellerstanislav commented 10 years ago

Datalayer class should contain some attribute, which would define default queryset (query manager) attribute. Nowadays, it's objects. But one could want something else, some non-default queryset. Maybe this should work:

class MongoengineDataLayer(Mongo):
    """
    Data layer for eve-mongoengine extension.
    Most of functionality is copied from :class:`eve.io.mongo.Mongo`.
    """
    json_encoder_class = MongoengineJsonEncoder
    _structured_fields = (EmbeddedDocumentField, DictField, MapField)
    # new attribute! ------------------------------------------------------
    default_queryset_attr = 'objects'
    # ---------------------------------------------------------------------
    ....