librelist archives

« back to archive

Import loop with MongoEngine

Import loop with MongoEngine

From:
Chris Higgins
Date:
2012-10-22 @ 21:32
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey all,

Sorry if this is something that is a little more simple to Flask or
Python, I?m still a little bit of a noob with Python. I?m using
flask-mongoengine to interact with my database, which I define in my
__init__.py file
(https://github.com/Chiggins/GoalCharge/blob/master/GoalCharge/__init__.py).
In that file, I also require my views.py file
(https://github.com/Chiggins/GoalCharge/blob/master/GoalCharge/views.py),
which in turn requires stuff from my models.py file
(https://github.com/Chiggins/GoalCharge/blob/master/GoalCharge/models.py),
which tries to import db from __init__.py. I?m basically creating a
loop of imports, so whenever I try to run the server straight from
command line, I get the following error http://pastebin.com/G5u9KX2F.

Not really sure where to go from here, I haven?t had a whole lot of
Flask/Python experience, so any help and advice would be appreciated.

Thanks!

- -- 
Chris Higgins
Student, Systems Administrator, Programmer
http://chigstuff.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQEcBAEBAgAGBQJQhbtVAAoJEKxPc59H45G1LUAH/AqayC12NVwxjzP6lzqFnp4R
TwjTiT77l61p3qK3ckCVvndTX76KGSijAPYNv17M/eChuaA1XY0P7etyNs1rcZa2
0Yk4GRbqYAzFbUlN+iiU1+QwdPovwabK7liFT+v9wMpQRdVVj66iFuc7BshNH2ld
9GVy1Ob2Wf6qAqt6gCHw3v8zYPQ7GX2P9xpps9YtmYf/JVcfXbDSm6SK1f74eB19
3RVHwbt83BWvvHI37g7iavalG/xt9XWjavtVgjSmc02XKl1JwLIFz6erM9ZDrcaj
Eom4//dcoz9hYS9HshlU6D/ldZcHRrsVJeLf5ITvGQo8k09+AxUuEN9BTsi1jpM=
=HO8y
-----END PGP SIGNATURE-----

Re: [flask] Import loop with MongoEngine

From:
Steven Kryskalla
Date:
2012-10-22 @ 21:36
On Mon, Oct 22, 2012 at 2:32 PM, Chris Higgins <chris@chigs.me> wrote:
> which tries to import db from __init__.py. I?m basically creating a
> loop of imports, so whenever I try to run the server straight from
> command line, I get the following error http://pastebin.com/G5u9KX2F.
>
> Not really sure where to go from here, I haven?t had a whole lot of
> Flask/Python experience, so any help and advice would be appreciated.

I didn't look at your code but it sounds like you're doing a circular
import. Try moving the import that's causing the problem to:

1. the bottom of the file
2. inside the first function it gets used from

There is a little description here of the problem:


http://docs.python.org/faq/programming.html#what-are-the-best-practices-for-using-import-in-a-module

-steve