I have a strange import problem. My directory structure is as follows:

/s/LysConf/
          Lib/__init__.py
              <various other files, SitePage.py et. al>
          MainContext/
                     <Main.py et. al, for the main context.>
          GenLib/
                 <Cheetah-generated *.py-files>
          LysCVSConfig/
                      __init__.py
                      Lib/
                          LysCVSPage.py
                      GenLib/ 
                             __init__.py
                             <Other Cheetah-Generated *.py-modules>
                      Context/
                             <Main.py et. al, for this context>.

(/s/LysConf is a Webware working directory)

My contexts setup in Applications.config is:

        'Contexts':             {'default':       'MainContext',
                                 'LysCVSConfig':
                                 'LysCVSConfig/Context'},

Now, from /s/LysConf/LysCVSConfig/Context/Main.py, I try to import a
class from a module in the /s/LysConf/LysCVSConfig/Lib package. The
source line looks like this:

from LysCVSConfig.Lib.LysCVSPage import LysCVSPage

But it fails, with the following traceback (excerpts from the WebKit
error page):

  Traceback

/s/LysConf/LysCVSConfig/Context/Main.py

Traceback (most recent call last):
  File "/s/Webware/WebKit/Application.py", line 416, in dispatchRequest
    self.handleGoodURL(transaction)
  File "/s/Webware/WebKit/Application.py", line 562, in handleGoodURL
    self.createServletInTransaction(transaction)
  File "/s/Webware/WebKit/Application.py", line 1023, in createServletInTransaction
    inst = self.getServlet(transaction,path,cache)
  File "/s/Webware/WebKit/Application.py", line 966, in getServlet
    inst = factory.servletForTransaction(transaction)
  File "/s/Webware/WebKit/ServletFactory.py", line 184, in servletForTransaction
    module = self.importAsPackage(transaction, path)
  File "/s/Webware/WebKit/ServletFactory.py", line 104, in importAsPackage
    module = self._importModuleFromDirectory(fullname, name, moduleDir, forceReload=1)
  File "/s/Webware/WebKit/ServletFactory.py", line 135, in _importModuleFromDirectory
    module = imp.load_module(fullModuleName, fp, pathname, stuff)
  File "/s/Webware/WebKit/ImportSpy.py", line 117, in load_module
    return modloader.load_module(name,(file,filename,description))
  File "/s/Webware/WebKit/ImportSpy.py", line 30, in load_module
    mod = ihooks.ModuleLoader.load_module(self, name, stuff)
  File "/usr/lib/python2.2/ihooks.py", line 270, in load_module
    m = self.hooks.load_source(name, filename, file)
  File "/usr/lib/python2.2/ihooks.py", line 168, in load_source
    return imp.load_source(name, filename, file)
  File "/s/LysConf/LysCVSConfig/Context/Main.py", line 1, in ?
    from LysCVSConfig.GenLib.LCVSMainTemplate import LCVSMainTemplate
  File "/usr/lib/python2.2/ihooks.py", line 398, in import_module
    m = self.load_tail(q, tail)
  File "/usr/lib/python2.2/ihooks.py", line 451, in load_tail
    raise ImportError, "No module named " + mname
ImportError: No module named LysCVSConfig.Lib


MiscInfo
filename /s/LysConf/LysCVSConfig/Context/Main.py  
os.getcwd() /s/LysConf  
sys.path ['', '/s/Webware', '/usr/lib/python2.2', '/usr/lib/python2.2/plat-linux2', 
'/usr/lib/python2.2/lib-tk', '/usr/lib/python2.2/lib-dynload', 
'/usr/local/lib/python2.2/site-packages', '/usr/lib/python2.2/site-packages', 
'/s/LysConf/Cache/PSP']  
time Tue Aug 5 20:09:51 2003  


The funny thing here is that if I do the following:

hostname:erik /s/LysConf % pwd
/s/LysConf
hostname:erik /s/LysConf % python
Python 2.2.2 (#1, Mar 21 2003, 23:01:54) 
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from LysCVSConfig.Lib.LysCVSPage import LysCVSPage
>>> 


..it works exactly as it should. 

Any hints on this? Is the import in Webware special? It seems to
handle one-level Packages without problems.

\EF                        
-- 
Erik Forsberg                 http://www.lysator.liu.se/~forsberg/
GPG/PGP Key: 1024D/0BAC89D9


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to