On Sun, 06 Nov 2005 09:47:04 -0500, David Mitchell <[EMAIL PROTECTED]> wrote:
>Thanks for your prompt reply. > >Ok, so If use your first suggestion (db = DataUtil.DataUtil() >), I get this error: > >AttributeError: 'module' object has no attribute 'DataUtil' > Have you looked to see what DataUtil you are importing? E.g., after import DataUtil, put a print repr(DataUtil.__file__) (is there a .pyc shadowing the .py you want? Is it from an unexpected directory? Have you looked at the search path that is in effect when you import? E.g., to print a list of the paths searched to find DataUtil.pyc (or if nonexistent or not up to date, DataUtil.py), you could do this import sys for p in sys.path: print p And then have you checked whether the above error message is telling the truth, i.e., that indeed DataUtil does not define DataUtil.DataUtil? Try doing help(DataUtil). >If I try importing the class directly (from DataUtil import DataUtil), >I get this error: > >ImportError: cannot import name DataUtil > Sure, the first error message would predict the latter one ;-) > >Could these errors have something to do with the fact that I am doing >this through mod_python? Could be, yes. I haven't used it, but I would guess it's a possibility. A server will generally be set up to run in a different environment than your normal login environment, so it's possible/probable that it has a different sys.path than you normally have, and even if not textually different, if the first element is '' to indicate current working directory that will generally be a different working from your normal login directory, depending on server config for responding to particular urls. It's possible to set up apache to run cgi impersonating a particular user account instead of the usual "nobody" or such (which generally has restricted file access), but it's probably "nobody" or some special user/group designed for security purposes, so you might want to check permissions on the files the server is supposed to be able to access for r, w, or x. There should be some standard test cgi stuff that will tell you about the environment. And hopefully also some wrapper to catch exceptions that might otherwise silently get lost (or show up in server error logs -- have you looked there?). You might want to put a try/except around your whole code, and burp out some carefully legal message page for the browser in case you catch something, e.g., if there were some exception in the DataUtil class body that prevented DataUtil.DataUtil from being defined. (And look for bare except: clauses or other exception handling that might be throwing away a DataUtil definition exception). HTH Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list