We need a quick help to resolve a critical issue.
We are using 0.4 version of mongoengine. We will be updating to latest
version, but that is a couple of weeks away.
We are facing a weird situation about DB connectivity.
Very recently we started using inheritance in our models. For ex.
Class A(Document): pass
Class B(A): pass
Class C(A): pass
With introduction of such classes, we are seeing _get_db() function is
being invoked on import of our B, C classes.
I traced further and found that in TopLevelDocumentMetaClass's new method,
where QuerySetManager is being instantiated and in turn descriptor __get__
is being called which is making _get_db() call.
Reason we have a problem with _get_db() being invoked during importing of
our modules, it creates a db connection with with default settings which
are "localhost:27017", which we want to avoid because we are reusing the
We want connection to be made on explicit call instead during the imports.
I did some digging in 0.5 code and it has changed significantly in those
areas where QuerySetManger is being defined.