Re: Circular imports between managers and models

2009-01-06 Thread Malcolm Tredinnick
On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote: > Hi, > Suppose I have two classes in "models.py", namely A and B. And there > is the manager for B as BManager in "managers.py". BManager makes use > of clas A. > > This situation leads to circular imports between "managers.py" and > "models.

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
On 6 jan, 19:45, Ben Eliott wrote: > Not that pretty/efficient but you could use contenttype contrib > temporarily. > IF ClassB has a ForeignKey to Class A could you extract the Class A > model from a foreign key via Class B's .meta? > Or the Class B could have a callable method which returned

Re: Circular imports between managers and models

2009-01-06 Thread Ben Eliott
Not that pretty/efficient but you could use contenttype contrib temporarily. IF ClassB has a ForeignKey to Class A could you extract the Class A model from a foreign key via Class B's .meta? Or the Class B could have a callable method which returned the instance of the model you want... No

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
on 6 jan, 14:54, Polat Tuzla wrote: (snip) > The reason why I need to separate models and managers into different > files is that they have simply grown to thousands of lines. > It's indeed a very compelling reason !-) But (simple suggestion - I know nothing about your project...) don't you see

Re: Circular imports between managers and models

2009-01-06 Thread Polat Tuzla
Yes, indeed! It's the models.Manager I'm talking about. I tried to keep my example short and easily comprehensible without code snippets, but i think I've achieved the opposite. Sorry for any inconvenience. Polat Tuzla On Jan 6, 3:37 pm, bruno desthuilliers wrote: > On 6 jan, 14:08, Lee Braiden

Re: Circular imports between managers and models

2009-01-06 Thread Polat Tuzla
Thank you very much for both of your responses. Local imports solved my problem. I had previously tried this without success, apparently there was another mistake in the code. Upon Bruno's suggestion I gave it another try, and it worked! The reason why I need to separate models and managers into

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
On 6 jan, 14:08, Lee Braiden wrote: > On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote: > > Hi, > > Suppose I have two classes in "models.py", namely A and B. And there > > is the manager for B as BManager in "managers.py". BManager makes use > > of clas A. > > > This situation leads to circu

Re: Circular imports between managers and models

2009-01-06 Thread bruno desthuilliers
On 6 jan, 13:42, Polat Tuzla wrote: > Hi, > Suppose I have two classes in "models.py", namely A and B. And there > is the manager for B as BManager in "managers.py". BManager makes use > of clas A. > > This situation leads to circular imports between "managers.py" and > "models.py" for which I ca

Re: Circular imports between managers and models

2009-01-06 Thread Lee Braiden
On Tue, 2009-01-06 at 04:42 -0800, Polat Tuzla wrote: > Hi, > Suppose I have two classes in "models.py", namely A and B. And there > is the manager for B as BManager in "managers.py". BManager makes use > of clas A. > > This situation leads to circular imports between "managers.py" and > "models.

Circular imports between managers and models

2009-01-06 Thread Polat Tuzla
Hi, Suppose I have two classes in "models.py", namely A and B. And there is the manager for B as BManager in "managers.py". BManager makes use of clas A. This situation leads to circular imports between "managers.py" and "models.py" for which I can't find a solution. Assuming that I need to sepa