From: Jason H. <ja...@pe...> - 2002-10-31 05:10:08
|
On Wed, 2002-10-30 at 16:56, Tom Harris wrote: > Greetings, > > I am about to try a real application using MiddleKit. What I want to do is > to install the Webware distribution under python/Lib/site-packages, but have > my app code in an unrelated directory, as this fits in with my existing > build system, and I can cleanly seperate files from a distribution from > files that are in source control. Good plan. > The directories that MiddleKit generates (for project Foo) are > - Middle > - Foo.mkmodel > - GeneratedPy > - GeneratedSQL > - Foo (my code in here) > > Can I put my code in directory `Foo` at the same level as `Middle`, and what > is the correct form of import to use? I think you'll be fine with your structure. The thing you have to watch out for is that you should always access stuff in the Middle directory as a package, doing something like: import Middle.User or from Middle.User import User Don't put the Middle directory itself in your python path and then import your Middle classes directly. import User > I have read the statement in the docs > to the effect that you should be careful not to multiply import the same > module, and I know the pain that this can cause, so I want to get it right. I have my code structured like this: Lib # contains miscellaneous support modules for my servlets Lib/Middle # contains the MiddleKit-generated stuff Lib/foo # a package which my servlets use Lib/bar # another package MyContext # contains my servlets, PSPs, etc. I add Lib to my PYTHONPATH before starting the appserver. That lets me do stuff like: import baz to import the file Lib/baz.py, and from Middle.User import User to get at the class in Lib/Middle/User.py. Hope this helps. -- Jason D. Hildebrand ja...@pe... |