On Sun, Jul 19, 2009 at 3:15 AM, Alec Henriksen<[email protected]> wrote: > Hello list, > > I've encountered a problem--possibly a bug, in the Storm ORM. > > It has to do with importing Storm objects into the local namespace. In > the Storm Tutorial, you encourage users to do this: > >>>> from storm.locals import * > > This works fine for when your module is in the parent directory for > storm. For example, I have a module named, "calendar.py" which connects > to a database (with Storm) and pulls records successfully. However, this > module (calendar.py) fails when I import it from another module > (ajax.py) in its parent directory. > > So, this is the structure: > > ajax.py > components/ > calendar.py > common.py > ... > storm/ > locals.py > > ajax.py imports calendar with this line: >>>> import components.calendar > > calendar.py imports Storm locals with this: >>>> from storm.locals import * > > Here is the error I get: > > Traceback (most recent call last): > File "ajax.py", line 15, in <module> > import components.calendar > File "/var/www/components/calendar.py", line 33, in <module> > from storm.locals import * > File "/var/www/components/storm/locals.py", line 21, in <module> > from storm.properties import Bool, Int, Float, RawStr, Chars, Unicode, > Pickle > ImportError: No module named storm.properties > > I'm using Python 2.6.2. > > Any idea what the issue is? Any idea how to fix it?
There are two things you could try. 1. add "from __future__ import absolute_imports" to the top of your source, which will make imports absolute by default (you'll need to use something like "from . import foo" to do a relative import with this turned on). This is how imports in a future version of Python 2.x will behave by default. 2. Don't name your modules in your code such that they conflict with existing top level modules. James. -- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
