jamestmcneill-python at yahoo.co.uk
jamestmcneill-python at yahoo.co.uk
Wed Sep 14 15:59:24 EDT 2005
Lee, Sorry for being crabbit, you didn't deserve it. Anyway I'm still on track of this PythonImport thing, and a couple of simple test rule out come possibilities. 1) I've run the main handler to show req.interpreter, and it is 'myinterpreter' as specified. 2) I've gone into IDLE and done what I'm trying to do in the main handler, namely: import mpglobals cur = mpglobals.con.cursor() That works correctly, and produces a compiled mpglobls.pyc in the same folder. Also I stuck some logger code into mpglobals, and that wrote to a text file as expected. 3) From this I can see that the PythonImport directive doesn't seem to be working at all (or at least, in any way I expected it to). It does not produce a compiled version of the module specified, nor does it run the logger code. However it works, it does not run as if I had an "import mpglobals" command in the main handler. In fact I've tried that, and it runs properly, showing that mpglobals is on sys.path within the main request handler, and that the code within it works properly. Really, as far as I can see (not far admittedly) either we're into some pretty weird territory with PythonImport and I'm just not getting all this C API and subinterpreter doodah, or it simply doesn't work under my configuration (Windows XP and Python 2.3). Can anyone suggest a simple test to show whether or not PythonImport is working at all on my system? Or have I already shown that it hasn't, with what I've done already? Cheers Jim --- Lee Brown wrote: > Greetings! > > It was not my intention to be condescending; rather, I was attempting to > be > in good humor and I apologize for the offense. In fact, I had the exact > same problem with imports and namespaces only a few months ago. > > If your object is still not accessible in the correct namespace, then > the > next thing to check is to see if your code is executing under the > interpreter name that you think it should. The example code that > Jorey > Bump published will help you determine this. > > I agree with you that doing an import once at server startup rather than > at > each request seems like a cleaner way to go. The only drawback is that > if > you change the code in the imported module you'll have to re-start the > server but this usually isn't a problem for many applications. > > Best Regards, > Lee E. Brown ++++++++++++++++++++++++++++++++++++++++++++++++++ + If you've got a good excuse - don't use it + ++++++++++++++++++++++++++++++++++++++++++++++++++)
|