[Zope] Another import doesn't find the module

Stacy Roberts Ladnier Stacy.Roberts@noaa.gov
Wed, 28 May 2003 12:48:29 -0500


First, I realized I did not need profile.py so I removed that line of 
code. What you say about not importing directories makes sense. However 
the following doesn't:

My Structure has the following
   -FGDC (directory)
       - __init__.py
       - profile.py
       - DISTRIB.py

The line I had that read 
   from Products.Resources.FGDC import profile 
failed as you said it should. 

However, this line works like a charm:
   from Products.Resources.FGDC import DISTRIB

BTW, I always interpreted this to mean
    from <directory> import <module>

Can you explain the *why's* on this one?? Even though I can move 
forward with my coding, my mind is still stuck on why this is?

Thanks,
Stacy
----- Original Message -----
From: Dylan Reinhardt <zope@dylanreinhardt.com>
Date: Wednesday, May 28, 2003 1:01 pm
Subject: Re: [Zope] Another import doesn't find the module

> Go back and look a little closer at the difference between what I 
> typedand what you're using.
> 
> Both your examples attempt to import from directories, something you
> simply can't do... at least not *this* way.  In Python, the word
> "module" refers, typically, to a .py file.  You can't find a module
> called FGDC because (according to your diagram) there isn't one.
> 
> Once you re-work import to import names from modules, I think you'll
> have better luck.
> 
> HTH,
> 
> Dylan
> 
> 
> 
> On Wed, 2003-05-28 at 10:06, Stacy Roberts Ladnier wrote:
> > I have tried both. The name of the class I am trying to import 
> is 
> > profile. So I put
> >     from Products.Resources.FGDC import profile 
> > and I get 'cannot import name profile'
> > 
> > When I try 
> >     from Products.Resources.FGDC import * 
> > I get 'no module named FGDC'. But I promise there is and there 
> is a 
> > __init__ file there this time. This module is used from many 
> other 
> > parts in my product.
> > 
> > I have the PYTHONPATH right and an __init__ in both the FGDC and 
> > extensions folders. I am at a loss for what is happening here.
> > 
> > Any help is appreciated, this is the last task before deployment.
> > 
> > Stacy
> > 
> > 
> > 
> > ----- Original Message -----
> > From: Dylan Reinhardt <zope@dylanreinhardt.com>
> > Date: Wednesday, May 28, 2003 10:38 am
> > Subject: Re: [Zope] Another import doesn't find the module
> > 
> > > This is a different problem.  I think what you want is:
> > > 
> > > import * from Products.Resources.FGDC.profile
> > > 
> > > or 
> > > 
> > > from Products.Resources.FGDC.profile import NAMES_GO_HERE
> > > 
> > > HTH,
> > > 
> > > Dylan
> > > 
> > > 
> > > On Wed, 2003-05-28 at 07:33, Stacy Roberts Ladnier wrote:
> > > > I am attempting to import another class for use and Zope now 
> > > > complains 'cannot import name profile'.
> > > > 
> > > > 
> > > > My Product structure in a bit more detail is:
> > > > 
> > > > Products
> > > >   - Resources
> > > >      -FGDC
> > > >          -__init__.py
> > > >          -profile.py
> > > >      -BIO
> > > >      -scripts
> > > >         -script1.py
> > > >      -dtml
> > > >      -www
> > > >      -extensions
> > > >         -DISTINFO.py which contains a class of the same name
> > > > 
> > > > In DISTINFO.py, I have an import statement like this:
> > > >        from Products.Resources.FGDC import profile
> > > > 
> > > > Can someone please tell me what I am doing wrong here??
> > > > 
> > > > Thanks in advance,
> > > > Stacy
> > > > 
> > > > 
> > > > 
> > > > 
> > > > _______________________________________________
> > > > Zope maillist  -  Zope@zope.org
> > > > http://mail.zope.org/mailman/listinfo/zope
> > > > **   No cross posts or HTML encoding!  **
> > > > (Related lists - 
> > > >  http://mail.zope.org/mailman/listinfo/zope-announce
> > > >  http://mail.zope.org/mailman/listinfo/zope-dev )
> > > 
> > > 
> > 
> > 
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://mail.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists - 
> >  http://mail.zope.org/mailman/listinfo/zope-announce
> >  http://mail.zope.org/mailman/listinfo/zope-dev )
> 
>