Apologies, for future reference it's useful if you paste the actual code that's failing alongside the error message (usually this is done by pasting the full traceback). It wasn't possible from the original paste to tell which import style you were using!
Glad it works! On Fri, Mar 21, 2014 at 12:00 PM, Zagloj <[email protected]> wrote: > Hi and sorry about the two messages, I write cause I tried relative > import like this (instead .models): > > from ..models import ( > DBSession, > MyModel, > ) > > > > And it works! Thanks very much, so cool the new template > for 1.5, a bit too red for my eyes but cool. > > The tests keep failing but that is another history that I think > belongs to test file code. > > El Thu, 20 Mar 2014 15:18:55 -0500 > Michael Merickel <[email protected]> escribió: > > Your original code should have been using "import mypkg.models" or > > "from mypkg import models" instead of "import models". The last one > > is ambiguous because it doesn't know which package to look in (and > > will not work on py3). This works for you previously because views.py > > and models.py were in the same subpackage and you're on py2 and as > > such python attempts to import that module from the same subpackage. > > > > Now that they are no longer in the same subpackage, you *must* be more > > specific with what module you want to import. For example "from > > mpkg.models import models". Alternatively you could use relative > > imports via "from .. import models". > > > > There are benefits to both the absolute and relative approaches but > > either way you should not treat your subpackages or submodules as > > top-level packages. It is explicitly unsupported in py3 and in py2 > > when using "from __future__ import absolute_imports". > > > > > > > > On Thu, Mar 20, 2014 at 2:52 PM, Zagloj <[email protected]> wrote: > > > > > Hi, I have a problem following the docs, I simply tried to modify > > > the structure from my scaffold but with no success, I followed > > > these steps: > > > > > > 1: Create the directory views and move the views.py to it > > > 2: Create empty __init__.py inside views directory > > > > > > I install it (/env/python setup.py develop) and then the test > > > (/env/python setup.py test) fail complaining about a lot of files, > > > then one last error: AttributeError: 'module' object has no > > > attribute 'views' > > > > > > When running pserve it complains about a lot of files and then: > > > > > > ImportError: No module named models > > > > > > Any help/hint/doc would be much appreciated. > > > > > > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/pylons-discuss. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
