Lee Brown
administrator at leebrown.org
Tue Sep 13 18:55:10 EDT 2005
Silly me! I meant to say: import mpglobals And not import mpglobals.py Sorry! Best Regards, Lee E. Brown (administrator at leebrown.org) -----Original Message----- From: mod_python-bounces at modpython.org [mailto:mod_python-bounces at modpython.org] On Behalf Of Lee Brown Sent: Tuesday, September 13, 2005 6:47 PM To: jamestmcneill-python at yahoo.co.uk; mod_python at modpython.org Subject: RE: [mod_python] PythonImport: Can someone please draw a diagramforthis idiot? No, I won't draw you a picture, but I'll give you a push in the right direction: If you were to use import mpglobals.py In any other ordinary python program, in what namespace would you expect to find the contents of mpglobals? Best Regards, Lee E. Brown (administrator at leebrown.org) -----Original Message----- From: mod_python-bounces at modpython.org [mailto:mod_python-bounces at modpython.org] On Behalf Of jamestmcneill-python at yahoo.co.uk Sent: Tuesday, September 13, 2005 10:38 AM To: mod_python at modpython.org Subject: [mod_python] PythonImport: Can someone please draw a diagram forthis idiot? Good afternoon. I wonder if someone may be able to help me get to the starting line with mod_python? I'm trying to use PythonImport to create a database connection which I can use for subsequent requests, and I haven't been able to figure out how. Here's what I'm putting in httpd.conf: PythonInterpreter maininterpreter PythonImport mpglobals maininterpreter <Directory "C:\Program Files\Apache Group\Apache2\htdocs\moddy"> AddHandler mod_python .py PythonHandler mptest PythonDebug On </Directory> mpglobals.py is in the "C:\Program Files\Apache Group\Apache2\htdocs\moddy" folder, and an entry in c:\python23\mp.pth adds this to sys.path. mpglobals.py attempts to load a database connection as global: import kinterbasdb as fbd con = fbd.connect(dsn='localhost:C:\Program Files\Firebird\Firebird_1_5\examples\employee.fdb', user='sysdba', password='masterkey') cur = con.cursor() Finally, the default python handler mptest.py tries to use the connection: def handler(req): cur.execute('select * from EMPLOYEE order by LAST_NAME') . . . . return apache.OK This throws up an error: File "C:/Program Files/Apache Group/Apache2/htdocs/moddy/\mptest.py", line 8, in handler cur.execute('select * from EMPLOYEE order by LAST_NAME') NameError: global name 'cur' is not defined Am I anywhere near going about this the right way? Can someone please draw me a diagram? Regards, Jim ++++++++++++++++++++++++++++++++++++++++++++++++++ + If you've got a good excuse - don't use it + ++++++++++++++++++++++++++++++++++++++++++++++++++) _______________________________________________ Mod_python mailing list Mod_python at modpython.org http://mailman.modpython.org/mailman/listinfo/mod_python _______________________________________________ Mod_python mailing list Mod_python at modpython.org http://mailman.modpython.org/mailman/listinfo/mod_python
|