Newbie Needs Help -- Name and Key errors

Fredrik Lundh effbot at telia.com
Tue Apr 25 12:28:34 EDT 2000


Bob Langdon <bingdo19 at earthlink.net> wrote:
> New to Python, and moving a site for a client. The backend sas developed
> by another developer in Python.  I've i9nstalled Python1.5.2 in my home
> direcpory and tested it. The interpreter seems to functioning properly.
>
> However, some paths seem to be defined incorrectly.
>
> When running a script "getresume.py" for example,
>
> >>try:
>    import sys
>    sys.stderr = sys.stdout
>    sys.path.insert(0,'.')
>    sys.path.append('/usr/local/lib/python1.5')
>    sys.path.append('/usr/local/lib/python1.5/site-packages')
>    import os
>    TEMPLATES=os.environ['DOCUMENT_ROOT']
>    from calendar import month_name
>    from types import *
>    from formhandler import FormHandler
>    from string import strip, split, join, atol, atof, upper, lower,
> capitalize
>    from refer import getReferer, addGetResume
>    from time import asctime, localtime, time, strftime
>    from urllib import quote_plus, unquote_plus
>    from fcsetup import LOCALHOSTNAME
>    from fcsetup import *
>    import Mail
> except:
>    print '<pre>\n'
>    import traceback
>    traceback.print_exc()
>    print sys.path
>
> resumeDIR = DEPOT

just guessing here, but it looks like

1) you need to the DOCUMENT_ROOT environment variable
before running the script

2) the fcsetup.py module should define a variable called DEPOT,
but doesn't.

> I think DEPOT might be a reference to the MySQL database, using the
> Berkley dbmodule (which I can't find). I certainly can't find a
> directory named DEPOT anywhere on the old host's server.

DEPT is a variable name, not a directory name.  the "from
fcsetup import *" line imports all variables from the fcsetup
module.

> Neither can I fathom where "DOCUMENT_ROOT" is defined, or find a file
> called "os.environ."

"os.environ" refers to a variable in the standard "os" module,
not a file.  see the library reference for more info.

</F>





More information about the Python-list mailing list