At 08:56 PM 6/5/2001 -0400, Jay Love wrote:
>Chuck Esterbrook wrote:
>
>>I ran into a problem where an "import Foo" was picking up the Foo in 
>>WebKit. Launch.py was previously tweaked to fix this but then got tweaked 
>>back. However, we don't ever want "import Foo" to assume WebKit.
>
>Because WebKit is a package, any modules in the WebKit package that call 
>"import Foo" should get WebKit.Foo first.  The WebKit part is 
>automatically appended.  That is why it doesn't matter in your servlets if 
>you say "from WebKit import Page" or just "import Page".  Either way, if 
>you look in sys.modules, you'll see WebKit.Page.

We had problems earlier where these 2 statements resulted in the module 
being loaded twice (which was flushed out by the assertion that the servlet 
really was a subclass of WebKit's Servlet):

         import Page
         import WebKit.Page

Contexts are now required to qualify WebKit in their imports as WebKit is 
it's own package. Only modules inside WebKit/ can (and should) use "import 
Foo" which is the natural, Pythonic style for importing "neighbor" modules 
in the same package.

Also, a .py in my context said "import Message" and got the Message inside 
of WebKit. That's not what was intended.


>>I made the following changes:
>>- Incorporated Geoff's path cleaning code from Cookie.py. No path ending 
>>in 'webkit' or equal to '.' is kept.
>>- '' is always the first sys.path element.
>
>Note that '' is not os.cwd.  '' is the directory the module calling 
>"import" is in.  Therefore, you ARE including WebKit, assuming you are 
>calling import from a module in the WebKit directory, or any subdirectory 
>(since its a package).  So that's not what you want.

No, that *is* what I want. If Foo.py and Bar.py exist in the same package, 
then the Pythonic way for them to access each other is via "import Bar" or 
"import Foo". However, everything outside the pkg should specify the pkg name.

Likewise, anything outside WebKit (e.g., a context) should also qualify 
WebKit, while things inside it should not.


>>- The cur dir becomes Webware/
>
>Why don't we eliminate this reliance on the cwd?  Why are you insisting on 
>that?

Because in the end, the combination of all these things I have listed works.


>I am not sure that everyone is on the same page on this path stuff.
>Clearly, I think I know, but so do you Chuck.  I don't like the reliance 
>on CWD, because it means that you may have to do some tricks to call it 
>from an init script or elsewhere.

What tricks? Can't you just do this:

python /foo/bar/Webware/WebKit/Launch.py ThreadedAppServer


-Chuck


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

Reply via email to