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 same connection.
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.
Unfortunately, that is the case with 0.4 in 0.5 we refactored how document / collections were initially setup and how we deal with creating capped collections etc.
Creating the connection before importing document models will stop mongoengine using its default connection settings.
On Mon, Feb 13, 2012 at 6:26 AM, sunil arora <arora.su...@gmail.com> wrote: > Hi,
> 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 > same connection.
> 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.
> Unfortunately, that is the case with 0.4 in 0.5 we refactored how document > / collections were initially setup and how we deal with creating capped > collections etc.
> Creating the connection before importing document models will stop > mongoengine using its default connection settings.
> Ross
> On Mon, Feb 13, 2012 at 6:26 AM, sunil arora <arora.su...@gmail.com>wrote:
>> Hi,
>> 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 >> same connection.
>> 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.
On Mon, Feb 13, 2012 at 11:02 AM, sunil arora <arora.su...@gmail.com> wrote: > Hi Ross,
> Thanks for the quick reply.
> If we have to upgrade from 0.4 to 0.5, what are key points that we should > keep in mind. Any breaking changes that we need to be aware about ?
> Thanks > Sunil
> On 13 February 2012 15:05, Ross Lawley <ross.law...@gmail.com> wrote:
>> Hi Sunil,
>> Unfortunately, that is the case with 0.4 in 0.5 we refactored how >> document / collections were initially setup and how we deal with creating >> capped collections etc.
>> Creating the connection before importing document models will stop >> mongoengine using its default connection settings.
>> Ross
>> On Mon, Feb 13, 2012 at 6:26 AM, sunil arora <arora.su...@gmail.com>wrote:
>>> Hi,
>>> 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 >>> same connection.
>>> 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.
> On Mon, Feb 13, 2012 at 11:02 AM, sunil arora <arora.su...@gmail.com>wrote:
>> Hi Ross,
>> Thanks for the quick reply.
>> If we have to upgrade from 0.4 to 0.5, what are key points that we should >> keep in mind. Any breaking changes that we need to be aware about ?
>> Thanks >> Sunil
>> On 13 February 2012 15:05, Ross Lawley <ross.law...@gmail.com> wrote:
>>> Hi Sunil,
>>> Unfortunately, that is the case with 0.4 in 0.5 we refactored how >>> document / collections were initially setup and how we deal with creating >>> capped collections etc.
>>> Creating the connection before importing document models will stop >>> mongoengine using its default connection settings.
>>> Ross
>>> On Mon, Feb 13, 2012 at 6:26 AM, sunil arora <arora.su...@gmail.com>wrote:
>>>> Hi,
>>>> 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 >>>> same connection.
>>>> 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.