Hi,

I used MiddleKit's Generate.py to generate "middle" objects from
Videos.mkmodel example.
In Settings.config I defined "Package" : "middle" to generate a package.
And of course I created __init__.py into the package directory.

This is my directory structure:
./
Home.py   -- this is a servlet
./middle
    __init__.py
    Videos.mkmodel/
    GeneratedPy/
        __init__.py
        GenMovie.py
        ...
    GeneratedSQL/
        ...
    Movie.py
    Video.py
    ...

in ./middle/__init__.py I have:
from MiddleKit.Run.MySQLObjectStore import MySQLObjectStore
modelFile = ...
store = MySQLObjectStore(user="sasha")
store.readModelFileNamed(modelFile)

in ./Home.py:
from middle import store
from middle.Movie import Movie     # <=== and the problem starts HERE!!!

When I try http://myhost/WK/MyContext I get exception:
...
  File "/home/sasha/spuni/Home.py", line 4, in ?
    from middle.Movie import Movie
  File "/home/sasha/spuni/middle/Movie.py", line 6, in ?
    from GeneratedPy.GenMovie import GenMovie
  File "/home/sasha/spuni/middle/GeneratedPy/GenMovie.py", line 8, in ?
    from middle.Video import Video
ImportError: No module named middle.Video

Obviously GenMovie.py wants to import middle.Video but python can not find
it in sys.path

This is what I found in GenMovie.py:
import sys
sys.path.insert(0, '../../')
from middle.Video import Video

so it inserts '../../' in sys.path and tries to import middle.Video (because
it is two levels up) but it fails.
When you insert a relative path into sys.path is it relative to the current
file or to the current directory ?
It seems that it means relative to the current directory.

Anybody of you generates middle objects as a package ?

-- Sasa



_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to