Here is my dilemma. Suppose that I've got the sources to my web
application in a directory called '/home/webapp'.
Inside that directory, I've got two packages:
And 'mar.py' refers to some function inside 'bar.py' by doing:
If I were using python on the command line, I could set my PYTHONPATH
variable to '/home/webapp' and run 'mar.py' just fine.
Now, lets say that my web application is mounted at context 'MyApp' in
Webware. The import statement from above in 'mar.py' won't work now. If
I change mar.py to use:
instead, then I can reference bar.py just fine.
The problem, though, is that now when I go back to the command line with
my PYTHONPATH set as above, it won't work (the import statement fails)
since python will be looking for a file at:
which doesn't exist. It's a tough break for me, too, since I need to
able to execute these classes from the command line for my unit testing.
I've tried doing some sys.path magic inside mar.py to manually add
'/home/webapp' to sys.path. That works great, but the one snag is that
sometimes webware will load the same class twice. Like there will be
something in sys.modules called both:
This makes total sense, since I've introduced ambiguity into sys.path.
And normally, having the classes loaded twice isn't a big deal. But I've
got a number of singleton classes that will wreak havoc if loaded more
I suppose I could prepend 'MyApp' to every inter-package import I do,
but I'd prefer to avoid hardcoding my web application context name into
Have any of you guys run into this sort of thing before? I was just
curious about what solutions you've come up with, or if I'm going about
this whole thing all wrong. :)
Thanks for your time!
University of Texas at Austin
Applied Research Laboratory